Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
d61eaf0d
Vérifiée
Valider
d61eaf0d
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
WIP: Adding lkt commands
parent
d18cc5b4
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!58
lkt update
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/main/lkt.c
+98
-11
98 ajouts, 11 suppressions
src/main/lkt.c
avec
98 ajouts
et
11 suppressions
src/main/lkt.c
+
98
−
11
Voir le fichier @
d61eaf0d
...
@@ -82,10 +82,7 @@ help(void)
...
@@ -82,10 +82,7 @@ help(void)
" Supported types are: title, [a]ny, source, [auth]or, [lang]uage, type, title
\n
"
" Supported types are: title, [a]ny, source, [auth]or, [lang]uage, type, title
\n
"
"
\n
"
"
\n
"
" RANGE:
\n
"
" RANGE:
\n
"
" A range is specified like in python:
\n
"
" A range is specified like BEGIN:END which implies from BEGIN to END included
\n
"
" - BEGIN:END which implies from BEGIN to END included
\n
"
" - :END which implies from the very begining to END included
\n
"
" - BEGIN: which implies from BEGIN to the very end included
\n
"
"
\n
"
;
"
\n
"
;
write
(
1
,
help_str
,
strlen
(
help_str
));
write
(
1
,
help_str
,
strlen
(
help_str
));
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
...
@@ -254,7 +251,7 @@ lkt_skip_key(char *buffer)
...
@@ -254,7 +251,7 @@ lkt_skip_key(char *buffer)
/* Functions implementing options. */
/* Functions implementing options. */
noreturn
void
noreturn
void
clear__
(
struct
lkt_cmd_args
*
args
)
queue_
clear__
(
struct
lkt_cmd_args
*
args
)
{
{
if
(
args
->
argc
!=
0
)
if
(
args
->
argc
!=
0
)
fail
(
"Invalid argument, the clear command takes no arguments"
);
fail
(
"Invalid argument, the clear command takes no arguments"
);
...
@@ -262,6 +259,15 @@ clear__(struct lkt_cmd_args *args)
...
@@ -262,6 +259,15 @@ clear__(struct lkt_cmd_args *args)
lkt_send_and_exit
(
cmd__
,
sizeof
(
cmd__
));
lkt_send_and_exit
(
cmd__
,
sizeof
(
cmd__
));
}
}
noreturn
void
queue_crop__
(
struct
lkt_cmd_args
*
args
)
{
if
(
args
->
argc
!=
0
)
fail
(
"Invalid argument, the crop command takes no arguments"
);
static
const
char
cmd__
[]
=
"crop
\n
close
\n
"
;
lkt_send_and_exit
(
cmd__
,
sizeof
(
cmd__
));
}
noreturn
void
noreturn
void
next__
(
struct
lkt_cmd_args
*
args
)
next__
(
struct
lkt_cmd_args
*
args
)
...
@@ -412,6 +418,47 @@ error:
...
@@ -412,6 +418,47 @@ error:
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
noreturn
void
queue_pop__
(
struct
lkt_cmd_args
*
args
)
{
if
(
args
->
argc
!=
0
)
fail
(
"Invalid argument, the status command takes no arguments"
);
int
ret
=
EXIT_FAILURE
,
songid
=
0
;
char
buff
[
LKT_MESSAGE_MAX
];
FILE
*
sock
=
lkt_connect
();
/* Get lektor's status. */
if
(
write_socket
(
sock
,
"status
\n
"
,
sizeof
(
"status
\n
"
)))
goto
error
;
#define assign_int(str, var) if (! strncmp(buff, str, len)) { var = (atoi(lkt_skip_key(buff))); continue; }
for
(;;)
{
memset
(
buff
,
0
,
LKT_MESSAGE_MAX
*
sizeof
(
char
));
if
(
read_socket
(
sock
,
buff
,
LKT_MESSAGE_MAX
-
1
)
<=
0
)
goto
error
;
size_t
len
=
strcspn
(
buff
,
LKT_KEY_VALUE_SEP
);
assign_int
(
"songid"
,
songid
)
/* At this point every key has been parsed. */
if
(
!
strncmp
(
buff
,
"OK"
,
2
))
break
;
else
if
(
!
strncmp
(
buff
,
"ACK"
,
3
))
goto
error
;
}
//fclose(sock);
if
(
!
songid
)
goto
error
;
write_socket_format
(
sock
,
"next
\n
deleteid %d
\n
"
,
songid
);
ret
=
EXIT_SUCCESS
;
error:
exit
(
ret
);
}
noreturn
void
noreturn
void
status__
(
struct
lkt_cmd_args
*
args
)
status__
(
struct
lkt_cmd_args
*
args
)
{
{
...
@@ -499,7 +546,7 @@ shuffle__(struct lkt_cmd_args *args)
...
@@ -499,7 +546,7 @@ shuffle__(struct lkt_cmd_args *args)
}
}
noreturn
void
noreturn
void
delete__
(
struct
lkt_cmd_args
*
args
)
queue_
delete__
(
struct
lkt_cmd_args
*
args
)
{
{
if
(
args
->
argc
!=
1
)
if
(
args
->
argc
!=
1
)
fail
(
"Invalid argument, need onlt one argument"
);
fail
(
"Invalid argument, need onlt one argument"
);
...
@@ -565,7 +612,30 @@ add__(struct lkt_cmd_args *args)
...
@@ -565,7 +612,30 @@ add__(struct lkt_cmd_args *args)
}
}
noreturn
void
noreturn
void
list__
(
struct
lkt_cmd_args
*
args
)
queue_seek__
(
struct
lkt_cmd_args
*
args
)
{
if
(
args
->
argc
!=
1
)
fail
(
"The seek command needs one argument"
);
char
*
endptr
,
buf
[
3
];
long
id
=
strtol
(
args
->
argv
[
0
],
&
endptr
,
0
);
if
((
errno
==
ERANGE
&&
(
id
==
LONG_MAX
||
id
==
LONG_MIN
))
||
(
errno
!=
0
&&
id
==
0
)
||
(
endptr
==
args
->
argv
[
0
]))
fail
(
"Invalid argument, not an integer"
);
if
(
*
endptr
!=
'\0'
)
fail
(
"Invalid argument, must be only one integer"
);
FILE
*
sock
=
lkt_connect
();
write_socket_format
(
sock
,
"playid %ld
\n
"
,
id
);
read_socket
(
sock
,
buf
,
2
);
exit
(
!
strncmp
(
buf
,
"OK"
,
2
));
}
noreturn
void
queue_pos__
(
struct
lkt_cmd_args
*
args
)
{
{
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
...
@@ -573,7 +643,7 @@ list__(struct lkt_cmd_args *args)
...
@@ -573,7 +643,7 @@ list__(struct lkt_cmd_args *args)
args
->
argv
=
LKT_QUEUE_DEFAULT
;
args
->
argv
=
LKT_QUEUE_DEFAULT
;
else
if
(
args
->
argc
>
1
)
else
if
(
args
->
argc
>
1
)
fail
(
"Invalid argument for the
queue
command"
);
fail
(
"Invalid argument for the
pos
command"
);
long
continuation
=
0
,
up
=
0
;
long
continuation
=
0
,
up
=
0
;
...
@@ -808,6 +878,16 @@ search_queue__(struct lkt_cmd_args *args)
...
@@ -808,6 +878,16 @@ search_queue__(struct lkt_cmd_args *args)
/* Parsing stuff. */
/* Parsing stuff. */
static
struct
lkt_cmd_opt
options_queue
[]
=
{
{
.
name
=
"pos"
,
.
call
=
queue_pos__
},
{
.
name
=
"pop"
,
.
call
=
queue_pop__
},
{
.
name
=
"seek"
,
.
call
=
queue_seek__
},
{
.
name
=
"delete"
,
.
call
=
queue_delete__
},
{
.
name
=
"clear"
,
.
call
=
queue_clear__
},
{
.
name
=
"crop"
,
.
call
=
queue_crop__
},
LKT_OPT_NULL
,
};
static
struct
lkt_cmd_opt
options_plt
[]
=
{
static
struct
lkt_cmd_opt
options_plt
[]
=
{
{
.
name
=
"help"
,
.
call
=
help__
},
{
.
name
=
"help"
,
.
call
=
help__
},
{
.
name
=
"add"
,
.
call
=
plt_add__
},
{
.
name
=
"add"
,
.
call
=
plt_add__
},
...
@@ -828,6 +908,15 @@ static struct lkt_cmd_opt options_search[] = {
...
@@ -828,6 +908,15 @@ static struct lkt_cmd_opt options_search[] = {
LKT_OPT_NULL
,
LKT_OPT_NULL
,
};
};
noreturn
void
queue__
(
struct
lkt_cmd_args
*
args
)
{
if
(
args
->
argc
==
0
)
fail
(
"Invalid argument, you must specify a sub command for the queue command"
);
lkt_cmd_parse
(
options_queue
,
args
->
argc
,
args
->
argv
,
help
);
}
noreturn
void
noreturn
void
search__
(
struct
lkt_cmd_args
*
args
)
search__
(
struct
lkt_cmd_args
*
args
)
{
{
...
@@ -848,13 +937,11 @@ plt__(struct lkt_cmd_args *args)
...
@@ -848,13 +937,11 @@ plt__(struct lkt_cmd_args *args)
static
struct
lkt_cmd_opt
options_
[]
=
{
static
struct
lkt_cmd_opt
options_
[]
=
{
{
.
name
=
"help"
,
.
call
=
help__
},
{
.
name
=
"help"
,
.
call
=
help__
},
{
.
name
=
"clear"
,
.
call
=
clear__
},
{
.
name
=
"current"
,
.
call
=
current__
},
{
.
name
=
"current"
,
.
call
=
current__
},
{
.
name
=
"play"
,
.
call
=
play__
},
{
.
name
=
"play"
,
.
call
=
play__
},
{
.
name
=
"delete"
,
.
call
=
delete__
},
{
.
name
=
"next"
,
.
call
=
next__
},
{
.
name
=
"next"
,
.
call
=
next__
},
{
.
name
=
"previous"
,
.
call
=
prev__
},
{
.
name
=
"previous"
,
.
call
=
prev__
},
{
.
name
=
"queue"
,
.
call
=
list
__
},
{
.
name
=
"queue"
,
.
call
=
queue
__
},
{
.
name
=
"add"
,
.
call
=
add__
},
{
.
name
=
"add"
,
.
call
=
add__
},
{
.
name
=
"shuffle"
,
.
call
=
shuffle__
},
{
.
name
=
"shuffle"
,
.
call
=
shuffle__
},
{
.
name
=
"status"
,
.
call
=
status__
},
{
.
name
=
"status"
,
.
call
=
status__
},
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter