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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
4dff7913
Vérifiée
Valider
4dff7913
rédigé
Il y a 5 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Correct the lkt queue command
parent
767024dc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!58
lkt update
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/main/lkt.c
+46
-62
46 ajouts, 62 suppressions
src/main/lkt.c
avec
46 ajouts
et
62 suppressions
src/main/lkt.c
+
46
−
62
Voir le fichier @
4dff7913
...
@@ -642,55 +642,35 @@ queue_seek__(struct lkt_cmd_args *args)
...
@@ -642,55 +642,35 @@ queue_seek__(struct lkt_cmd_args *args)
}
}
noreturn
void
noreturn
void
queue_
list
__
(
struct
lkt_cmd_args
*
args
)
queue_
pos
__
(
struct
lkt_cmd_args
*
args
)
{
{
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
FILE
*
sock
=
NULL
;
long
continuation
=
0
,
up
=
0
,
song_index
=
1
;
/* Arguments stuff. */
if
(
args
->
argc
!=
1
)
fail
(
"Invalid argument for the pos command"
);
if
(
args
->
argc
==
0
)
long
continuation
=
0
,
up
=
0
;
args
->
argv
=
LKT_QUEUE_DEFAULT
;
else
if
(
args
->
argc
!=
1
)
fail
(
"Invalid argument"
);
continuation
=
strtol
(
args
->
argv
[
0
],
&
endptr
,
0
);
continuation
=
strtol
(
args
->
argv
[
0
],
&
endptr
,
0
);
if
((
errno
==
ERANGE
&&
(
continuation
==
LONG_MAX
||
continuation
==
LONG_MIN
))
||
(
errno
!=
0
if
((
errno
==
ERANGE
&&
(
continuation
==
LONG_MAX
||
continuation
==
LONG_MIN
))
||
(
errno
!=
0
&&
continuation
==
0
)
||
(
endptr
==
args
->
argv
[
0
]))
&&
continuation
==
0
)
||
(
endptr
==
args
->
argv
[
0
]))
fail
(
"Invalid argument, not an integer"
);
fail
(
"Invalid argument, not an integer"
);
if
(
*
endptr
!=
'\0'
)
if
(
*
endptr
!=
'\0'
)
{
fail
(
"Invalid argument"
);
/* A range */
if
(
*
(
++
endptr
)
==
'\0'
)
/* Get the current pos to get limits for the playlist command. */
fail
(
"Invalid argument, a range is two integers"
);
sock
=
lkt_connect
();
up
=
atoi
(
endptr
);
if
(
write_socket
(
sock
,
"status
\n
"
,
sizeof
(
"status
\n
"
)))
fail
(
"Communication 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
)
fail
(
"Connextion error"
);
size_t
len
=
strcspn
(
buff
,
LKT_KEY_VALUE_SEP
);
assign_int
(
"song"
,
song_index
);
/* At this point every key has been parsed. */
if
(
!
strncmp
(
buff
,
"OK"
,
2
))
break
;
else
if
(
!
strncmp
(
buff
,
"ACK"
,
3
))
exit
(
EXIT_FAILURE
);
}
}
/* Get the content of the queue. */
song_index
=
MAX
(
song_index
,
1
);
FILE
*
sock
=
NULL
;
fclose
(
sock
);
redo:
redo:
sock
=
lkt_connect
();
sock
=
lkt_connect
();
if
(
up
!=
0
)
write_socket_format
(
sock
,
"playlist %d:%d
\n
"
,
continuation
,
up
);
write_socket_format
(
sock
,
"playlist %d:%d
\n
"
,
continuation
,
up
);
else
write_socket_format
(
sock
,
"playlist %d
\n
"
,
continuation
);
for
(;;)
{
for
(;;)
{
memset
(
buff
,
0
,
LKT_MESSAGE_MAX
*
sizeof
(
char
));
memset
(
buff
,
0
,
LKT_MESSAGE_MAX
*
sizeof
(
char
));
...
@@ -714,55 +694,59 @@ redo:
...
@@ -714,55 +694,59 @@ redo:
}
}
noreturn
void
noreturn
void
queue_
pos
__
(
struct
lkt_cmd_args
*
args
)
queue_
list
__
(
struct
lkt_cmd_args
*
args
)
{
{
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
char
buff
[
LKT_MESSAGE_MAX
],
*
endptr
;
FILE
*
sock
=
NULL
;
long
continuation
=
0
,
song_index
=
1
;
if
(
args
->
argc
!=
1
)
/* Arguments stuff. */
fail
(
"Invalid argument for the pos command"
);
long
continuation
=
0
,
up
=
0
;
if
(
args
->
argc
==
0
)
args
->
argv
=
LKT_QUEUE_DEFAULT
;
else
if
(
args
->
argc
!=
1
)
fail
(
"Invalid argument"
);
continuation
=
strtol
(
args
->
argv
[
0
],
&
endptr
,
0
);
continuation
=
strtol
(
args
->
argv
[
0
],
&
endptr
,
0
);
if
((
errno
==
ERANGE
&&
(
continuation
==
LONG_MAX
||
continuation
==
LONG_MIN
))
||
(
errno
!=
0
if
((
errno
==
ERANGE
&&
(
continuation
==
LONG_MAX
||
continuation
==
LONG_MIN
))
||
(
errno
!=
0
&&
continuation
==
0
)
||
(
endptr
==
args
->
argv
[
0
]))
&&
continuation
==
0
)
||
(
endptr
==
args
->
argv
[
0
]))
fail
(
"Invalid argument, not an integer"
);
fail
(
"Invalid argument, not an integer"
);
if
(
*
endptr
!=
'\0'
)
{
if
(
*
endptr
!=
'\0'
)
/* A range */
fail
(
"Invalid argument"
);
if
(
*
(
++
endptr
)
==
'\0'
)
fail
(
"Invalid argument, a range is two integers"
);
up
=
atoi
(
endptr
);
}
/* Get the current pos to get limits for the playlist command. */
FILE
*
sock
=
NULL
;
redo:
sock
=
lkt_connect
();
sock
=
lkt_connect
();
if
(
up
!=
0
)
if
(
write_socket
(
sock
,
"status
\n
"
,
sizeof
(
"status
\n
"
))
)
write_socket_format
(
sock
,
"playlist %d:%d
\n
"
,
continuation
,
up
);
fail
(
"Communication error"
);
else
write_socket_format
(
sock
,
"playlist %d
\n
"
,
continu
ation
);
#define assign_int(str, var) if (! strncmp(buff, str, len)) { var = (atoi(lkt_skip_key(buff)));
continu
e; }
for
(;;)
{
for
(;;)
{
memset
(
buff
,
0
,
LKT_MESSAGE_MAX
*
sizeof
(
char
));
memset
(
buff
,
0
,
LKT_MESSAGE_MAX
*
sizeof
(
char
));
assert
(
read_socket
(
sock
,
buff
,
LKT_MESSAGE_MAX
-
1
)
>
0
);
if
(
read_socket
(
sock
,
buff
,
LKT_MESSAGE_MAX
-
1
)
<=
0
)
fail
(
"Connextion error"
);
if
(
!
strncmp
(
buff
,
"continue:"
,
strlen
(
"continue:"
)))
{
size_t
len
=
strcspn
(
buff
,
LKT_KEY_VALUE_SEP
);
continuation
=
atoi
(
lkt_skip_key
(
buff
));
assign_int
(
"song"
,
song_index
);
if
(
continuation
>
0
)
{
fclose
(
sock
);
goto
redo
;
}
}
/* At this point every key has been parsed. */
if
(
!
strncmp
(
buff
,
"OK"
,
2
))
if
(
!
strncmp
(
buff
,
"OK"
,
2
))
exit
(
EXIT_SUCCESS
)
;
break
;
else
if
(
!
strncmp
(
buff
,
"ACK"
,
3
))
else
if
(
!
strncmp
(
buff
,
"ACK"
,
3
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
fprintf
(
stdout
,
"%s"
,
buff
);
}
}
fclose
(
sock
);
/* Get the content of the queue. */
song_index
=
MAX
(
song_index
+
1
,
1
);
snprintf
(
buff
,
LKT_MESSAGE_MAX
-
1
,
"%ld:%ld"
,
song_index
,
song_index
+
continuation
-
1
);
buff
[
LKT_MESSAGE_MAX
-
1
]
=
'\0'
;
args
->
argc
=
1
;
args
->
argv
[
0
]
=
buff
;
queue_pos__
(
args
);
}
}
/* Functions implementing options, but for for playlists. */
/* Functions implementing options, but for for playlists. */
...
...
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