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
11a0abb0
Vérifiée
Valider
11a0abb0
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Can now create URIs from a list of strings
parent
55995b64
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!98
Queue and playlist interactions with lkt
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/uri.c
+61
-29
61 ajouts, 29 suppressions
src/uri.c
avec
61 ajouts
et
29 suppressions
src/uri.c
+
61
−
29
Voir le fichier @
11a0abb0
...
...
@@ -9,21 +9,18 @@
#include
<errno.h>
#include
<limits.h>
bool
lkt_uri_from
(
struct
lkt_uri
*
ret
,
char
*
const
str
)
static
inline
char
*
__prefix
(
char
*
str
,
struct
lkt_uri
*
ret
)
{
char
*
val
,
*
endptr
;
char
*
val
;
size_t
len
;
long
id
;
if
(
ret
==
NULL
||
str
==
NULL
)
return
false
;
len
=
strlen
(
str
);
if
(
!
str
||
!
ret
)
return
NULL
;
/
/
The minimal uri is id://1 which is a 6 characters long
if
(
len
<
=
5
*
sizeof
(
char
)
)
return
false
;
/
*
The minimal uri is id://1 which is a 6 characters long
*/
if
(
(
len
=
strlen
(
str
))
<=
5
)
return
NULL
;
if
(
STR_NMATCH
(
str
,
"id"
,
2
))
{
ret
->
type
=
uri_id
;
...
...
@@ -47,35 +44,70 @@ lkt_uri_from(struct lkt_uri *ret, char *const str)
ret
->
type
=
uri_query
;
val
=
str
+
5
;
}
else
return
false
;
return
NULL
;
/
/
No place for the '://' separator
/
*
No place for the '://' separator
*/
if
(
len
-
(
val
-
str
)
<
3
)
return
false
;
return
NULL
;
val
+=
3
;
ret
->
value
=
val
;
return
val
;
}
if
(
ret
->
type
==
uri_id
)
{
id
=
strtol
(
val
,
&
endptr
,
10
);
bool
lkt_uri_from
(
struct
lkt_uri
*
ret
,
char
*
const
str
)
{
if
(
NULL
==
__prefix
(
str
,
ret
))
return
false
;
if
((
errno
==
ERANGE
&&
(
id
==
LONG_MAX
||
id
==
LONG_MIN
))
||
(
errno
!=
0
&&
id
==
0
)
||
endptr
==
str
)
if
(
ret
->
type
==
uri_id
)
{
errno
=
0
;
ret
->
id
=
strtol
(
ret
->
value
,
NULL
,
10
);
/* Override */
if
(
errno
!=
0
)
return
false
;
}
ret
->
value
=
calloc
(
1
,
sizeof
(
int
));
ret
->
_allocated
=
false
;
return
true
;
}
if
(
ret
->
value
==
NULL
)
return
false
;
bool
lkt_uri_from_list
(
struct
lkt_uri
*
ret
,
char
**
list
)
{
int
i
;
if
(
!
list
||
!
list
[
0
])
return
false
;
*
(
int
*
)
ret
->
value
=
id
;
ret
->
_allocated
=
true
;
}
if
(
!
list
[
1
])
return
lkt_uri_from
(
ret
,
list
[
0
]);
if
(
NULL
==
__prefix
(
list
[
0
],
ret
))
return
false
;
/* Nothing after the separator */
if
(
'\0'
==
*
(
char
*
)
ret
->
value
)
return
false
;
char
*
buffer
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
strlen
(
ret
->
value
)
+
1
));
if
(
NULL
==
buffer
)
return
false
;
strcpy
(
buffer
,
ret
->
value
);
for
(
i
=
1
;
list
[
i
];
++
i
)
{
char
*
new
=
realloc
(
buffer
,
strlen
(
buffer
)
+
1
+
strlen
(
list
[
i
])
+
1
);
if
(
NULL
==
new
)
{
free
(
buffer
);
return
false
;
}
else
{
ret
->
_allocated
=
false
;
ret
->
value
=
val
;
buffer
=
new
;
strcat
(
buffer
,
" "
)
;
strcat
(
buffer
,
list
[
i
])
;
}
ret
->
value
=
buffer
;
ret
->
_allocated
=
true
;
return
true
;
}
...
...
@@ -110,8 +142,8 @@ __lkt_to_str(struct lkt_uri *uri, char *ret, size_t len)
safe_snprintf
(
ret
,
len
,
"search=%s"
,
(
char
*
)
uri
->
value
);
break
;
default:
LOG_
ERROR
(
"URI"
,
"type %d may not be supported by kurisu, "
"generate an error"
,
uri
->
type
);
LOG_
WARN
(
"URI"
,
"type %d may not be supported by kurisu, "
"generate an error"
,
uri
->
type
);
return
1
;
}
...
...
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