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 (8)
......@@ -4,6 +4,7 @@
- Add json-c to the download dependency script (add cmake as a requirement for that)
- Choose between static or shared library for liblektor
- Download the bakabase with obfuscation or not
- Implicit types for queries with lkt
# v2.1 (df74b85f)
......
/* Types available in the database */
kara_type("OP")
kara_type("ED")
kara_type("AMV")
kara_type("IS")
kara_type("LIVE")
kara_type("CDG")
kara_type("PV")
kara_type("MV")
/* Categories available in the database */
kara_category("vo")
kara_category("va")
kara_category("amv")
kara_category("cdg")
kara_category("autres")
kara_category("vocaloid")
/* Languages available in the database */
kara_language("jp")
kara_language("fr")
kara_language("en")
kara_language("ru")
kara_language("sp")
kara_language("it")
kara_language("ch")
kara_language("latin")
kara_language("multi")
kara_language("undefined")
// vi:syntax=c
lkt_manpages = lektor.man lektord.man lkt.man
lkt_manpages = lektor.man lektord.man lkt.man lkt.old.man
notrans_dist_man1_MANS = $(lkt_manpages)
MAN = $(abs_top_srcdir)/scripts/manpage.bash
CLEANFILES = $(lkt_manpages)
......
......@@ -286,7 +286,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
lkt_manpages = lektor.man lektord.man lkt.man
lkt_manpages = lektor.man lektord.man lkt.man lkt.old.man
notrans_dist_man1_MANS = $(lkt_manpages)
CLEANFILES = $(lkt_manpages)
all: all-am
......
.\" vim: ft=groff
.SH "FILES"
.PD 0
.TP
......@@ -11,5 +12,6 @@
\fIlektor\fP(1),
\fIlektord\fP(1),
\fIlkt\fP(1),
\fIlkt.old\fP(1),
\fImpc\fP(1),
\fImpd\fP(1)
.\" vim: ft=groff
.TH "LEKTOR" "1" "___DATE___" "LEKTOR MK 7"
.SH "NAME"
......@@ -14,6 +15,8 @@ You may be interested in other related programs like:
\fIlektord\fP The lektor daemon
.TP
\fIlkt\fP A standard client for lektord
.TP
\fIlkt.old\fP A standard client for lektord, the old and deprecated version
.PD
.SH "DESCRIPTION"
......@@ -35,6 +38,7 @@ Lektord can be piloted over the network with \fBlkt\fP.
\fBPlaylists and stickers\fP
Reading and searching through the base can be facilitated by creating
\fIplaylist\fP and using \fIstickers\fP (\fIMPD\fP version of tags).
.SH "INSTALLATION"
You may install lektor from source like this:
.sp
......@@ -109,7 +113,7 @@ The supported languages in lektor are: \fBjp\fP, \fBfr\fP, \fBsp\fP, \fBen\fP,
.SH "SUPPORTED TYPES"
The supported types in lektor are: \fBOP\fP, \fBED\fP, \fBIS\fP, \fBAMV\fP,
\fBVOCA\fP, \fBMV\fP, \fBPV\fP and \fBLIVE\fP.
\fBMV\fP, \fBPV\fP and \fBLIVE\fP.
.SH "SUPPORTED CATEGORIES"
The supported categories in lektor are: \fBvo\fP, \fBva\fP, \fBcdg\fP,
......@@ -152,9 +156,10 @@ be gotten here: \fBhttps://www.musicpd.org/doc/html/protocol.html#\fP.
.SH "AUTHOR AND AVAILABILITY"
Lektor is a karaoke player for POSIX compliant systems (i.e. not MS-Windows)
writen initially in C. Some may call it Lektor mk 7. It was writen by Hubert
\'Taiite' HIRTZ, Maël 'Kubat' MARTIN and Louis 'Elliu' GOYARD. These people
also helped: Loïc 'Sting' ALLÈGRE and Etienne 'Pelle' BRATEAU.
writen initially in C. Some may call it Lektor mk7. It was writen by Maël
\'Kubat' MARTIN, Hubert \'Taiite' HIRTZ and Louis \'Elliu' GOYARD. These people
also helped with some ideas or debugging: Loïc \'Sting' ALLÈGRE and Etienne
\'Pelle' BRATEAU.
.PP
The up\-to\-date source code is available via Git from Gitlab\&. See
\fBhttps://git\&.iiens\&.net/martin2018/lektor\fP. The source code is
......@@ -171,5 +176,9 @@ about lektor.
.TP
\fBhttps://manga.iiens.net\fP The home website for the Bakaclub
.TP
\fBirc.iiens.net:7000/#manga\fP The irc channel
\fBirc.iiens.net:7000/#manga\fP The general irc channel
.TP
\fBirc.iiens.net:7000/#baka-dev\fP The developpement irc channel
.TP
\fBirc.iiens.net:7000/#baka-dev-lektor\fP The developpement irc channel specific to lektor
.PD
.\" vim: ft=groff
.TH "LEKTORD" "1" "___DATE___" "LEKTOR MK 7"
.SH "NAME"
......@@ -7,12 +8,6 @@ lektord \- the lektor daemon
The lektord is only the lektor's daemon. It may need other scripts and/or
external programs to work correctly.
.PP
You may be interested in other related programs like:
.PP
.PD 0
.TP
\fIlkt\fP A standard client for lektord
.PD
.SH "DESCRIPTION"
.PP
......
.\" vim: ft=groff
.TH "LKT.OLD" "1" "___DATE___" "LEKTOR MK 7"
.SH "NAME"
lkt.old \- the old lektor command line client, kept for some back-compatibility issues
.PP
\fB/!\\ Deprecated /!\\\fP
.SH "OVERVIEW"
\fBlkt.old\fP is the old \fBlektord\fP client, much like \fBmpc\fP but with
more functionnalities like \fIplaylists\fP and \fIstickers\fP management.
.PP
Because \fBlkt.old\fP is replaced by \fBlkt\fP, its usage is deprecated in
favor of \fBlkt\fP. The differences are the following:
.IP \[bu] 2
Some types in queries are optional. Thus the type is infered from the regex
part and it means that some \fIqueries\fP are no longer possible.
.PP
Commands can be used with the minimal name that permit them to be
distinguished from others commands. Thus, it is possible to use the
string \fIadm\fP as an alias for \fIadmin\fP. This is like cisco switch
command line interface.
.PP
.SH "COMMANDS"
Here are the \fBlkt.old\fP commands:
.PP
\fIBASE-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBcurrent\fP
Prints informations about the currently playing kara. Can be used to
display the current kara in a status bar like \fBxmobar\fP or in the
\fBi3 panel\fP
.TP
\fBplay\fP [index]
Toggle play/pause state. If the playback is stopped, start at a possibly
specified index
.TP
\fBnext\fP
Play next kara in the queue
.TP
\fBprevious\fP
Play the previous kara in the queue
.TP
\fBshuffle\fP
Shuffle the queue. If the state was stoppped, play from the first kara
in the queue. If lektor was already playing a kara, it will play it
from the begening. The current kara will be placed in first position
in the queue.
.TP
\fBstatus\fP
Prints information about the state of lektor and the currently playing kara
.TP
\fBstop\fP
Stop the playback and reading the queue, the state is now \fIstopped\fP.
.PP
\fIPLAYLIST-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBplt create\fP <plt-name>
Creates a playlist, do nothing if it was already present
.TP
\fBplt destroy\fP <plt-name>
Delete a playlist with all its content, do nothing if the playlist didn't exists
.TP
\fBplt delete\fP <plt-name> <query>
Deletes karas from a playlist with a valid \fIquery\fP
.TP
\fBplt add\fP <plt-name> <query>
Adds karas to a playlist with a valid \fIquery\fP
.TP
\fBplt list\fP <plt-name>
List the content of the playlist named <plt-name>
.TP
\fBplt list\fP
List all the available playlists
.PP
\fIQUEUE-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBqueue\fP [count]
Prints the names and ids of the next karas in the queue
.TP
\fBqueue pos\fP <pos | from:to>
Prints the names and ids of karas in the queue. Karas can be designated by
their position or with a range
.TP
\fBqueue pop\fP
Delete the currently playing kara from the queue and pass to the next one.
This can work only if the currently playong kara is not the last
.TP
\fBqueue add\fP <query>
Add karas to the queue at the end of it with a valid query
.TP
\fBqueue insert\fP <query>
Add karas to the queue just after the currently playing kara
.TP
\fBqueue seek\fP <id>
Goto to the kara with the specified id in the queue
.TP
\fBqueue delete\fP <id>
Delete karas from the playlist with their id. You can't delete the currently
playing kara, for that use the \fBpop\fP queue command
.TP
\fBqueue clear\fP
Clear the queue and set the state to \fIstopped\fP
.TP
\fBqueue crop\fP
Crop the queue, delete every kara from it appart from the currently
playing one
.TP
\fBqueue replace\fP <plt-name>
Replace the queue with the content of a playlist. Keep the playling state
.PP
\fISEARCH-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBsearch database\fP <query>
Search and prints the kara that correspond to the query in the database
.TP
\fBsearch plt\fP <plt-name> <query>
Search, prints and add to an existing playlist the karas that match
the query
.TP
\fBsearch plt\fP <plt-name>
List the content of the playlist named <plt-name>
.TP
\fBsearch plt\fP
List all the available playlists
.TP
\fBsearch count\fP <query>
Search and prints the number of karas that match the query
.TP
\fBsearch get\fP <id>
Get informations about a specific id
.TP
\fBsearch queue\fP <query>
Search in the queue and prints the karas that match the query
.PP
\fISTICKERS-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBsticker create\fP <name>
Create a sticker that can be used to tag \fIkara\fP and \fIplt\fP objects
.TP
\fBsticker get\fP <type> <uri> [ <name> [ <op> <value> ] ]
List the stickers of an object \fIuri\fP. The object \fItype\fP can be
\fIkara\fP or \fIplt\fP
A condition can be defined on the value of the sticker with an operator
\fIop\fP and an integer value \fIvalue\fP. Supported operators are \fIl\fP
for 'less than', \fIe\fP for 'equal to' and \fIg\fP for 'greater than'.
Operations are not strict
.TP
\fBsticker set\fP <type> <uri> <name> <value>
Set the value of a sticker \fIname\fP to \fIvalue\fP for the object with the
id \fIuri\fP
.TP
\fBsticker delete\fP <type> <uri> [name]
Delete all the stickers or only one (specified by \fIname\fP) of the object
with the id \fIuri\fP
.PP
\fIADMIN-COMMANDS\fP
.PP
.PD 0
.TP
.PD
\fBadmin ping\fP
Pings the lektord daemon, prints \fIOK\fP only if the ping succeeded
.TP
\fBadmin kill\fP
Kill the lektord daemon
.TP
\fBadmin restart\fP
Try to restart the lektord daemon
.TP
\fBadmin rescan\fP
Rescan karas from the filesystem. New karas that are not in the database
will be added to it. Don't synchronize from the repo
.TP
\fBadmin populate\fP
Force a rescan (without taking into account the timestamp). Can be used
to bootstrap the database from a filesystem
.TP
\fBadmin update\fP
Update the base from the \fIKurisu\fP repo. Don't scan for new files in
the filesystem
.TP
\fBadmin config\fP
Prints to \fIstdout\fP the default configuration file
.PP
.SH "OPTIONS"
Options can be passed to \fBlkt.old\fP before specifying the command in a
\fIoption=value\fP format. This is done this way to allow one to make an alias
of the \fBlkt.old\fP command.
.PP
The possible options are the following:
.PP
.PD 0
.TP
.PD
\fBhost\fP
The hostname or the IP of the machine where the \fBlektord\fP daemon
is running
.TP
\fBport\fP
The port on which the \fBlektord\fP daemon is listening
.TP
\fBpwd\fP
The password to use for commands that require authentification. This is the
case of most of the \fIadmin\fP commands
.PP
.SH "QUERIES"
Queries are a way of listing karas in the database. They are composed of a
type and the next of the line is the SQL regex that the kara must verify.
In SQL regexes, the wildcard is the "%" character and the jocker the
character "_". Queries are case insensitive.
.PP
Valid types for a query are the following: \fIid\fP, \fIlang\fP, \fItype\fP,
\fIcategory\fP, \fIauthor\fP, \fIquery\fP and \fIplaylist\fP.
.PP
For the type \fItype\fP, the valid values are the following: \fIOP\fP,
\fIED\fP, \fIIS\fP, \fIAMV\fP, \fIMV\fP, \fIPV\fP and \fILIVE\fP.
.PP
For the type \fIlang\fP, the valid values are the following: \fIjp\fP,
\fIfr\fP, \fIsp\fP, \fIen\fP, \fIlatin\fP, \fIit\fP, \fIru\fP, \fImulti\fP
and \fIundefined\fP.
.PP
For the \fIcategory\fP type, the valid values are the following:
\fIvo\fP, \fIva\fP, \fIcdg\fP, \fIamv\fP, \fIvocaloid\fP and \fIautres\fP.
.PP
Here are some examples of queries:
.PP
.PD 0
.TP
.PD
\fBtype OP\fP
Select karas that are openings
.TP
\fBauthor kubat\fP
Select karas where the author is "kubat"
.PP
.SH "EXAMPLES"
Valid invocations of the \fBlkt.old\fP command are the following:
.PP
.PD 0
.TP
.PD
\fBlkt.old host=sakura port=6601 pwd=toto admin restart\fP
Restart the lektord daemon on the \fIsakura\fP PC. This daemon is listening on
the port \fI6601\fP and the password of the admin user is \fItoto\fP
.TP
\fBlkt.old q a author krocoh\fP
Add kara that Krocoh has done to the queue
.\" vim: ft=groff
.TH "LKT" "1" "___DATE___" "LEKTOR MK 7"
.SH "NAME"
lkt \- the lektor command line client
.SH "OVERVIEW"
\fBlkt\fP is the \fBlektord\fP client, much like \fBmpc\fP but with
more functionnalities like \fIplaylists\fP and \fIstickers\fP management.
......@@ -12,17 +15,10 @@ distinguished from others commands. Thus, it is possible to use the
string \fIadm\fP as an alias for \fIadmin\fP. This is like cisco switch
command line interface.
.PP
You may be interested in other related programs like:
.PP
.PD 0
.TP
\fIlektord\fP The lektor daemon
.TP
.PD
.SH "COMMANDS"
Here are the \fBlkt\fP commands:
.PP
\fIBASE-COMMANDS\fP
.PP
......@@ -204,6 +200,7 @@ the filesystem
Prints to \fIstdout\fP the default configuration file
.PP
.SH "OPTIONS"
Options can be passed to \fBlkt\fP before specifying the command in a
\fIoption=value\fP format. This is done this way to allow one to make
......@@ -226,37 +223,71 @@ The password to use for commands that require authentification. This is the
case of most of the \fIadmin\fP commands
.PP
.SH "QUERIES"
Queries are a way of listing karas in the database. They are composed of a
type and the next of the line is the SQL regex that the kara must verify.
In SQL regexes, the wildcard is the "%" character and the jocker the
character "_". Queries are case insensitive.
.PP
Queries are a way of listing karas in the database. They are composed of an
optional type (see when it is not optional) and the next of the line is the SQL
regex that the kara must verify. In SQL regexes, the wildcard is the "%"
character and the jocker the character "_". Queries are case insensitive (in
most cases).
.IP \[bu] 2
Valid types for a query are the following: \fIid\fP, \fIlang\fP, \fItype\fP,
\fIcategory\fP, \fIauthor\fP, \fIquery\fP and \fIplaylist\fP.
.PP
.IP \[bu]
For the type \fItype\fP, the valid values are the following: \fIOP\fP,
\fIED\fP, \fIIS\fP, \fIAMV\fP, \fIVOCA\fP, \fIMV\fP, \fIPV\fP and \fILIVE\fP.
.PP
\fIED\fP, \fIIS\fP, \fIAMV\fP, \fIMV\fP, \fIPV\fP and \fILIVE\fP.
.IP \[bu]
For the type \fIlang\fP, the valid values are the following: \fIjp\fP,
\fIfr\fP, \fIsp\fP, \fIen\fP, \fIlatin\fP, \fIit\fP, \fIru\fP, \fImulti\fP
and \fIundefined\fP.
\fIfr\fP, \fIsp\fP, \fIen\fP, \fIlatin\fP, \fIit\fP, \fIru\fP, \fImulti\fP and
\fIundefined\fP.
.IP \[bu]
For the \fIcategory\fP type, the valid values are the following: \fIvo\fP,
\fIva\fP, \fIcdg\fP, \fIamv\fP, \fIvocaloid\fP and \fIautres\fP.
.PP
For the \fIcategory\fP type, the valid values are the following:
\fIvo\fP, \fIva\fP, \fIcdg\fP, \fIamv\fP, \fIvocaloid\fP and \fIautres\fP.
For the following types of queries, the type part is optional: \fIid\fP,
\fItype\fP, \fIlang\fP, \fIcategory\fP. The other optional type is the
\fIquery\fP type, be carefull with that type of query! The optional type of
queries are recognise as such when reding the regex part:
.IP \[bu] 2
\fI'type'\fP: If the regex is all in upper case, it will be treated as a
\fItype\fP of kara, if the \fItype\fP is invalid \fBlkt\fP will return an
error. This means that you can't do any other queries with only upper case
characters.
.IP \[bu]
\fI'id'\fP: If the regex is a number, it will be treated as an \fIid\fP. This
means that you can't search the database with a unique number as a \fIquery\fP
but it should not be a problem.
.IP \[bu]
\fI'lang'\fP and \fI'category'\fP: If the regex is in lower case and matches a
\fIlang\fP or a \fIcategory\fP, the type will be infered.
.IP \[bu]
\fI'query'\fP: If no other type is infered and no type is recognised (the query
does not begin by \fIauthor\fP, \fIplaylist\fP), then all the regex is
considered to be a \fIquery\fP.
.PP
Here are some examples of queries:
.PP
.PD 0
.TP
.PD
\fBtype OP\fP
\fBtype OP\fP / \fBOP\fP
Select karas that are openings
.TP
\fB6000\fP
Select the kara with the id 6000
.TP
\fBauthor kubat\fP
Select karas where the author is "kubat"
Select karas where the author is "kubat" or "Kubat" or etc
.TP
\fBtonari%no%totoro\fP
Select karas that match the query "%tonari%no%totoro%"
.PP
.SH "EXAMPLES"
Valid invocations of the \fBlkt\fP command are the following:
.PP
......
......@@ -84,9 +84,10 @@ EXTRA_DIST = database/disk.sql database/memory.sql
## MAIN FILES ##
################
bin_PROGRAMS = lektord lkt
bin_PROGRAMS = lektord lkt.old lkt
## The lkt client
lkt_old_SOURCES = main/lkt-old.c base/cmd.c base/common.c
lkt_SOURCES = main/lkt.c base/cmd.c base/common.c
## The lektord server
......
......@@ -99,7 +99,7 @@ host_triplet = @host@
# TODO pour le Kubat du futur: c'est pas beau, trouver un truc pour que ça se fasse tout seul
@LKT_STATIC_MODULE_TRUE@am__append_8 = module/thread.c
bin_PROGRAMS = lektord$(EXEEXT) lkt$(EXEEXT)
bin_PROGRAMS = lektord$(EXEEXT) lkt.old$(EXEEXT) lkt$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/m4/libtool.m4 \
......@@ -212,6 +212,10 @@ am_lkt_OBJECTS = main/lkt.$(OBJEXT) base/cmd.$(OBJEXT) \
base/common.$(OBJEXT)
lkt_OBJECTS = $(am_lkt_OBJECTS)
lkt_LDADD = $(LDADD)
am_lkt_old_OBJECTS = main/lkt-old.$(OBJEXT) base/cmd.$(OBJEXT) \
base/common.$(OBJEXT)
lkt_old_OBJECTS = $(am_lkt_old_OBJECTS)
lkt_old_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
......@@ -245,7 +249,8 @@ am__depfiles_remade = base/$(DEPDIR)/cmd.Po base/$(DEPDIR)/common.Po \
database/$(DEPDIR)/liblektor_la-queue.Plo \
database/$(DEPDIR)/liblektor_la-stickers.Plo \
database/$(DEPDIR)/liblektor_la-update.Plo \
database/$(DEPDIR)/liblektor_la-user.Plo main/$(DEPDIR)/lkt.Po \
database/$(DEPDIR)/liblektor_la-user.Plo \
main/$(DEPDIR)/lkt-old.Po main/$(DEPDIR)/lkt.Po \
main/$(DEPDIR)/server.Po mkv/$(DEPDIR)/liblektor_la-mkv.Plo \
mkv/$(DEPDIR)/liblektor_la-utils.Plo \
mkv/$(DEPDIR)/liblektor_la-write.Plo \
......@@ -277,10 +282,11 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(liblektor_la_SOURCES) $(liblktmodrepo_la_SOURCES) \
$(liblktmodsdl_la_SOURCES) $(lektord_SOURCES) $(lkt_SOURCES)
$(liblktmodsdl_la_SOURCES) $(lektord_SOURCES) $(lkt_SOURCES) \
$(lkt_old_SOURCES)
DIST_SOURCES = $(am__liblektor_la_SOURCES_DIST) \
$(liblktmodrepo_la_SOURCES) $(liblktmodsdl_la_SOURCES) \
$(lektord_SOURCES) $(lkt_SOURCES)
$(lektord_SOURCES) $(lkt_SOURCES) $(lkt_old_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
......@@ -477,6 +483,7 @@ liblektor_la_LDFLAGS = -avoid-version -pthread -lsqlite3 \
@LKT_STATIC_MODULE_TRUE@liblektor_la_LIBADD = liblktmodsdl.la liblktmodrepo.la
CLEANFILES = database/disk.c database/memory.c
EXTRA_DIST = database/disk.sql database/memory.sql
lkt_old_SOURCES = main/lkt-old.c base/cmd.c base/common.c
lkt_SOURCES = main/lkt.c base/cmd.c base/common.c
lektord_SOURCES = main/server.c
lektord_LDADD = liblektor.la
......@@ -744,6 +751,12 @@ base/common.$(OBJEXT): base/$(am__dirstamp) \
lkt$(EXEEXT): $(lkt_OBJECTS) $(lkt_DEPENDENCIES) $(EXTRA_lkt_DEPENDENCIES)
@rm -f lkt$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lkt_OBJECTS) $(lkt_LDADD) $(LIBS)
main/lkt-old.$(OBJEXT): main/$(am__dirstamp) \
main/$(DEPDIR)/$(am__dirstamp)
lkt.old$(EXEEXT): $(lkt_old_OBJECTS) $(lkt_old_DEPENDENCIES) $(EXTRA_lkt_old_DEPENDENCIES)
@rm -f lkt.old$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lkt_old_OBJECTS) $(lkt_old_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
......@@ -782,6 +795,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@database/$(DEPDIR)/liblektor_la-stickers.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@database/$(DEPDIR)/liblektor_la-update.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@database/$(DEPDIR)/liblektor_la-user.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@main/$(DEPDIR)/lkt-old.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@main/$(DEPDIR)/lkt.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@main/$(DEPDIR)/server.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@mkv/$(DEPDIR)/liblektor_la-mkv.Plo@am__quote@ # am--include-marker
......@@ -1203,6 +1217,7 @@ distclean: distclean-am
-rm -f database/$(DEPDIR)/liblektor_la-stickers.Plo
-rm -f database/$(DEPDIR)/liblektor_la-update.Plo
-rm -f database/$(DEPDIR)/liblektor_la-user.Plo
-rm -f main/$(DEPDIR)/lkt-old.Po
-rm -f main/$(DEPDIR)/lkt.Po
-rm -f main/$(DEPDIR)/server.Po
-rm -f mkv/$(DEPDIR)/liblektor_la-mkv.Plo
......@@ -1281,6 +1296,7 @@ maintainer-clean: maintainer-clean-am
-rm -f database/$(DEPDIR)/liblektor_la-stickers.Plo
-rm -f database/$(DEPDIR)/liblektor_la-update.Plo
-rm -f database/$(DEPDIR)/liblektor_la-user.Plo
-rm -f main/$(DEPDIR)/lkt-old.Po
-rm -f main/$(DEPDIR)/lkt.Po
-rm -f main/$(DEPDIR)/server.Po
-rm -f mkv/$(DEPDIR)/liblektor_la-mkv.Plo
......
Ce diff est replié.
......@@ -24,6 +24,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <limits.h>
#include <ctype.h>
#define LKT_KEY_VALUE_SEP ": \n\t\0"
#define fail_if(cond, msg) { if (cond) { LOG_ERROR("LKT", "%s", msg); exit(EXIT_FAILURE); } }
......@@ -54,16 +55,104 @@ static const char *LKT_QUEUE_DEFAULT[] = { "10" };
/* Communication functions and fonction that interact with lektor stuff. */
static inline void
__concat_strings(char *const res, size_t len, const char **tab, size_t count)
{
size_t i;
for (i = 0; i < count - 1; ++i) {
strncat(res, tab[i], len - 1);
strncat(res, " ", len - 1);
}
strncat(res, tab[i], len - 1);
}
static int
lkt_valid_type(const char *type)
lkt_get_query_type(struct cmd_args *args, char *const regex, size_t regex_len)
{
return (STR_MATCH(type, "query") ||
STR_MATCH(type, "category") ||
STR_MATCH(type, "author") ||
STR_MATCH(type, "lang") ||
STR_MATCH(type, "id") ||
STR_MATCH(type, "type") ||
STR_MATCH(type, "playlist"));
if (args->argc == 0) {
LOG_ERROR("LKT", "Invalid empty query");
return 1;
}
/* id, type, lang, category */
if (args->argc == 1) {
/* Type ?== id */
long id = 0;
errno = 0;
id = strtol(args->argv[0], NULL, 10);
if (id != 0 && errno == 0) {
safe_snprintf(regex, regex_len, "id://%ld", id);
return 0;
}
/* Type ?== type OR Type ?== category OR Type ?== lang */
#define kara_type(tp) \
if (STR_MATCH(tp, args->argv[0])) { \
safe_snprintf(regex, regex_len, "type://%s", args->argv[0]); \
return 0; \
}
#define kara_category(ct) \
if (STR_MATCH(ct, args->argv[0])) { \
safe_snprintf(regex, regex_len, "category://%s", args->argv[0]); \
return 0; \
}
#define kara_language(lg) \
if (STR_MATCH(lg, args->argv[0])) { \
safe_snprintf(regex, regex_len, "lang://%s", args->argv[0]); \
return 0; \
}
#include <lektor/database.def>
#undef kara_category
#undef kara_language
#undef kara_type
}
memset(regex, 0, regex_len * sizeof(char));
/* author, playlist/plt */
if (args->argc >= 2) {
/* Type ?== author */
if (STR_MATCH("author", args->argv[0])) {
strncat(regex, "author://", regex_len - 1);
__concat_strings(regex, regex_len, args->argv + 1, args->argc - 1);
return 0;
}
/* Type ?== playlist */
else if (STR_MATCH("plt", args->argv[0]) || STR_MATCH("playlist", args->argv[0])) {
strncat(regex, "playlist://", regex_len - 1);
__concat_strings(regex, regex_len, args->argv + 1, args->argc - 1);
return 0;
}
/* Explicit type for lang, category and type */
/* Type ?== category */
else if (STR_MATCH("cat", args->argv[0]) || STR_MATCH("category", args->argv[0])) {
strncat(regex, "category://", regex_len - 1);
safe_snprintf(regex, regex_len, "category://%s", args->argv[0]);
return 0;
}
/* Type ?== lang */
else if (STR_MATCH("lang", args->argv[0]) || STR_MATCH("language", args->argv[0])) {
safe_snprintf(regex, regex_len, "lang://%s", args->argv[0]);
return 0;
}
/* Type ?== type */
if (STR_MATCH("type", args->argv[0])) {
safe_snprintf(regex, regex_len, "type://%s", args->argv[0]);
return 0;
}
}
/* If 'query' is specified, skip it */
int index = STR_MATCH("query", args->argv[0]) ? 1 : 0;
strncat(regex, "query://%", regex_len - 1);
__concat_strings(regex, regex_len, args->argv + index, args->argc - index);
strncat(regex, "%", regex_len - 1);
return 0;
}
static int
......@@ -156,15 +245,14 @@ lkt_skip_key(char *buffer)
static inline void
send_cmd_with_uri(FILE *sock, char *cmd, int argc, const char **argv)
{
int i;
char buf[LKT_MESSAGE_MAX] = {0};
for (i = 1; i < argc - 1; ++i) {
strncat(buf, argv[i], LKT_MESSAGE_MAX - 1);
strncat(buf, " ", LKT_MESSAGE_MAX - 1);
}
strncat(buf, argv[i], LKT_MESSAGE_MAX - 1);
strncat(buf, "\n", LKT_MESSAGE_MAX - 1);
write_socket(sock, "%s %s://%s", cmd, argv[0], buf);
char buf[LKT_MESSAGE_MAX];
struct cmd_args args = {
.argc = argc,
.argv = argv,
};
memset(buf, 0, LKT_MESSAGE_MAX * sizeof(char));
fail_if(lkt_get_query_type(&args, buf, LKT_MESSAGE_MAX), "Query is invalid");
write_socket(sock, "%s %s\n", cmd, buf);
}
/* Functions implementing options. */
......@@ -232,8 +320,6 @@ rescan_or_update__(struct cmd_args *args, const char *cmd)
if (!password)
fail("Password not provided");
FILE *sock = lkt_connect();
char buff[LKT_MESSAGE_MAX];
int i;
/* All the db */
if (args->argc == 0) {
......@@ -245,9 +331,9 @@ rescan_or_update__(struct cmd_args *args, const char *cmd)
/* With a query */
else {
char buff[LKT_MESSAGE_MAX];
memset(buff, 0, LKT_MESSAGE_MAX * sizeof(char));
for (i = 0; i < args->argc; ++i)
strncat(buff, args->argv[i], LKT_MESSAGE_MAX - 1);
fail_if(lkt_get_query_type(args, buff, LKT_MESSAGE_MAX), "Query is not valid");
write_socket(sock, "command_list_begin\n");
write_socket(sock, "password %s\n", password);
write_socket(sock, "%s %s\n", cmd, buff);
......@@ -610,7 +696,6 @@ queue_add__(struct cmd_args *args)
{
char buff[3];
fail_if(args->argc < 1, "Invalid arguments");
fail_if(!lkt_valid_type(args->argv[0]), "Invalid query type");
FILE *sock = lkt_connect();
send_cmd_with_uri(sock, "add", args->argc, args->argv);
exit_with_status(sock, buff);
......@@ -621,7 +706,6 @@ queue_insert__(struct cmd_args *args)
{
char buff[3];
fail_if(args->argc < 1, "Invalid arguments");
fail_if(!lkt_valid_type(args->argv[0]), "Invalid query type");
FILE *sock = lkt_connect();
send_cmd_with_uri(sock, "__insert", args->argc, args->argv);
exit_with_status(sock, buff);
......@@ -759,21 +843,18 @@ noreturn void
plt_add__(struct cmd_args *args)
{
char buff[2];
FILE *sock = lkt_connect();
fail_if(args->argc < 3,
fail_if(args->argc < 2,
"Invalid argument, need at least three arguments: plt add <plt> <query>");
fail_if(!lkt_valid_type(args->argv[1]), "Invalid argument, type for the query is invalid");
int i;
char buf[LKT_MESSAGE_MAX] = {0};
for (i = 2; i < args->argc - 1; ++i) {
strncat(buf, args->argv[i], LKT_MESSAGE_MAX - 1);
strncat(buf, " ", LKT_MESSAGE_MAX - 1);
}
strncat(buf, args->argv[i], LKT_MESSAGE_MAX - 1);
strncat(buf, "\n", LKT_MESSAGE_MAX - 1);
write_socket(sock, "playlistadd %s %s://%s", args->argv[0], args->argv[1], buf);
char regex[LKT_MESSAGE_MAX];
struct cmd_args args_regex = {
.argc = args->argc - 1,
.argv = args->argv + 1,
};
fail_if(lkt_get_query_type(&args_regex, regex, LKT_MESSAGE_MAX), "Query is invalid");
FILE *sock = lkt_connect();
write_socket(sock, "playlistadd %s %s\n", args->argv[0], regex);
exit_with_status(sock, buff);
}
......@@ -898,19 +979,16 @@ list_plt_content__(struct cmd_args *args)
noreturn void
search_with_cmd__(struct cmd_args *args, const char *cmd)
{
fail_if(args->argc < 2, "Invalid number of arguments");
fail_if(!lkt_valid_type(args->argv[0]), "Invalid type for the query");
char buff[LKT_MESSAGE_MAX];
int continuation = 0, i;
char regex[LKT_MESSAGE_MAX];
int continuation = 0;
FILE *sock = NULL;
fail_if(lkt_get_query_type(args, regex, LKT_MESSAGE_MAX), "Query is invalid");
redo:
sock = lkt_connect();
write_socket(sock, "%d %s %s://", continuation, cmd, args->argv[0]);
for (i = 1; i < args->argc - 1; ++i)
write_socket(sock, "%s ", args->argv[i]);
write_socket(sock, "%s\n", args->argv[i]);
write_socket(sock, "%d %s %s\n", continuation, cmd, regex);
for (;;) {
memset(buff, 0, LKT_MESSAGE_MAX * sizeof(char));
......@@ -959,19 +1037,20 @@ search_plt__(struct cmd_args *args)
if (args->argc == 1)
list_plt_content__(args);
fail_if(args->argc < 3, "Invalid number of arguments");
fail_if(!lkt_valid_type(args->argv[1]), "Invalid type for query");
char buff[LKT_MESSAGE_MAX];
int continuation = 0, i;
char regex[LKT_MESSAGE_MAX];
int continuation = 0;
FILE *sock = NULL;
struct cmd_args args_regex = {
.argc = args->argc - 1,
.argv = args->argv + 1,
};
fail_if(args->argc < 2, "Invalid number of arguments");
fail_if(lkt_get_query_type(&args_regex, regex, LKT_MESSAGE_MAX), "Query is invalid");
redo:
sock = lkt_connect();
write_socket(sock, "%d listplaylistinfo %s %s://", continuation,
args->argv[0], args->argv[1]);
for (i = 2; i < args->argc - 1; ++i)
write_socket(sock, "%s ", args->argv[i]);
write_socket(sock, "%s\n", args->argv[i]);
write_socket(sock, "%d listplaylistinfo %s %s\n", continuation, args->argv[0], regex);
for (;;) {
memset(buff, 0, LKT_MESSAGE_MAX * sizeof(char));
......@@ -1106,7 +1185,7 @@ parse_args(args_t *args, int argc, const char **argv)
size_t len;
for (i = 1; i < argc && i < 3; ++i) {
len = strcspn(argv[i], "=");
len = strcspn(argv[i], "=:");
if (STR_NMATCH("host", argv[i], len)) {
args->host = (argv[i] + len + 1);
......@@ -1134,9 +1213,8 @@ main(int argc, const char **argv)
__log_level = ERROR;
executable_name = "lkt";
assert(NULL != setlocale(LC_ALL, "en_US.UTF-8")); /* BECAUSE! */
if (signal(SIGPIPE, sigpipe__)) {
// LOG_ERROR("SYS", "%s", "Failed to install handler for SIGPIPE signal");
}
if (signal(SIGPIPE, sigpipe__))
LOG_ERROR("SYS", "Failed to install handler for SIGPIPE signal (you may be using php...)");
args_t args = {
.host = "localhost",
......