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
3a9354e0
Vérifiée
Valider
3a9354e0
rédigé
4 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
BASE: Completion call for the json parser
parent
64aecb75
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!130
Resolve "Remove json-c"
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
inc/lektor/json.h
+7
-5
7 ajouts, 5 suppressions
inc/lektor/json.h
src/base/json.c
+4
-6
4 ajouts, 6 suppressions
src/base/json.c
avec
11 ajouts
et
11 suppressions
inc/lektor/json.h
+
7
−
5
Voir le fichier @
3a9354e0
...
...
@@ -12,15 +12,17 @@
// *INDENT-OFF*
typedef
void
(
*
json_parse_callback
)(
const
char
*
key
,
/* Json key, a string */
const
char
*
value
,
/* Json value, a string */
int
new_obj
,
/* 1 when
encountered a new object
*/
void
*
user
/* The user pointer from the parse function */
const
char
*
key
,
/* Json key, a string
*/
const
char
*
value
,
/* Json value, a string
*/
int
completed
,
/* 1 when
all values in the object has been parsed
*/
void
*
user
/* The user pointer from the parse function
*/
);
// *INDENT-ON*
/* Parse only one level of json, simple but only what we need for lektor. The
* callback is used when a couple key/value is found for the correct level. */
* callback is used when a couple key/value is found for the correct level.
* When the json object has been completed, call the callback with the
* 'completed' argument at 1, 'key' and 'value' will be NULL. */
int
json_parse
(
const
char
*
str
,
int
level
,
json_parse_callback
,
void
*
user
);
#endif
/* __LKT_JSON_H__ */
Ce diff est replié.
Cliquez pour l'agrandir.
src/base/json.c
+
4
−
6
Voir le fichier @
3a9354e0
...
...
@@ -94,7 +94,6 @@ int
json_parse
(
const
char
*
str
,
int
asked_level
,
json_parse_callback
call
,
void
*
user
)
{
int
level
=
0
;
int
new_obj
=
1
;
int
is_paren
=
0
;
char
key
[
LKT_LINE_MAX
];
char
val
[
LKT_LINE_MAX
];
...
...
@@ -105,14 +104,15 @@ json_parse(const char *str, int asked_level, json_parse_callback call, void *use
/* Begin of a block */
if
((
len
=
strspn
(
str
,
__JSON_BEGIN
)))
{
new_obj
=
1
;
level
+=
len
;
str
+=
len
;
}
/* End of a block */
else
if
((
len
=
strspn
(
str
,
__JSON_END
)))
{
new_obj
=
1
;
if
(
level
==
asked_level
)
{
call
(
NULL
,
NULL
,
1
,
user
);
}
str
+=
len
;
level
-=
len
;
}
...
...
@@ -127,9 +127,7 @@ json_parse(const char *str, int asked_level, json_parse_callback call, void *use
__NEXT_JSON
(
str
,
len
,
is_paren
,
val
);
if
(
asked_level
==
level
)
call
(
key
,
val
,
new_obj
,
user
);
new_obj
=
0
;
call
(
key
,
val
,
0
,
user
);
}
if
(
level
<=
0
)
{
...
...
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