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
a001a1ec
Vérifiée
Valider
a001a1ec
rédigé
Il y a 4 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
MODULE: First step in downloading fav list...
parent
61e859a8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!130
Resolve "Remove json-c"
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/base/json.c
+13
-6
13 ajouts, 6 suppressions
src/base/json.c
src/module/module_repo.c
+14
-18
14 ajouts, 18 suppressions
src/module/module_repo.c
avec
27 ajouts
et
24 suppressions
src/base/json.c
+
13
−
6
Voir le fichier @
a001a1ec
...
...
@@ -31,15 +31,14 @@
len = (end - str); \
is_paren = 1; \
} else \
len = strcspn(str, __JSON_SPACE
__JSON_BEGIN __JSON_END);
\
len = strcspn(str, __JSON_SPACE
);
\
if (level == asked_level && len < LKT_LINE_MAX - 1) \
strncpy(dest, str, len); \
str += len; \
/* Also decode '\"' => '"' */
\
if (is_paren) { \
++str; \
__replace(key, "\\\"", "\""); \
__replace(val, "\\\"", "\""); \
__replace(dest, "\\\"", "\""); \
} \
}
...
...
@@ -62,6 +61,10 @@
} else \
len = strcspn(str, __JSON_SPACE __JSON_BEGIN __JSON_END); \
str += len; \
/* Also decode '\"' => '"' */
\
if (is_paren) { \
++str; \
} \
}
/* WARN: strlen(from) >= strlen(to) */
...
...
@@ -101,6 +104,8 @@ json_parse(const char *str, int asked_level, json_parse_callback call, void *use
char
key
[
LKT_LINE_MAX
];
char
val
[
LKT_LINE_MAX
];
LOG_DEBUG
(
"JSON"
,
"Begin parsing of json"
);
for
(;;)
{
size_t
len
=
0
;
__SKIP_JSON
(
str
);
...
...
@@ -113,8 +118,10 @@ json_parse(const char *str, int asked_level, json_parse_callback call, void *use
/* End of a block */
else
if
((
len
=
strspn
(
str
,
__JSON_END
)))
{
if
(
level
==
asked_level
)
if
(
level
==
asked_level
)
{
LOG_DEBUG
(
"JSON"
,
"Completion call for json object"
);
call
(
NULL
,
NULL
,
1
,
user
);
}
str
+=
len
;
level
-=
len
;
}
...
...
@@ -169,7 +176,7 @@ json_parse_get_count(const char *str, int asked_level)
}
if
(
level
<=
0
)
return
len
;
return
ret_
len
;
}
return
-
1
;
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/module/module_repo.c
+
14
−
18
Voir le fichier @
a001a1ec
...
...
@@ -62,13 +62,6 @@ struct module_repo_internal {
char
*
get_fav_json
;
const
uint64_t
version
;
/* Worker threads */
struct
worker_pool
workers
;
pthread_mutex_t
mtx
;
/* Protect the updating field */
// *INDENT-OFF*
volatile
unsigned
int
updating
:
REPO_UPDATE_TYPE_COUNT
;
/* The correct size */
// *INDENT-ON*
/* The database and the queue */
struct
queue
*
queue
;
volatile
sqlite3
*
db
;
...
...
@@ -78,6 +71,13 @@ struct module_repo_internal {
* - len: the length of the string, not its size (which is PATH_MAX)
* - kara: the kara structure, which contains all the data to create the filename */
void
(
*
craft_filename
)(
char
str
[
PATH_MAX
],
size_t
,
struct
kara
*
);
/* Worker threads */
// *INDENT-OFF*
volatile
unsigned
int
updating
:
REPO_UPDATE_TYPE_COUNT
;
/* The correct size */
// *INDENT-ON*
pthread_mutex_t
mtx
;
/* Protect the updating field */
struct
worker_pool
workers
;
};
struct
__uri
{
...
...
@@ -517,12 +517,10 @@ end_no_lock:
}
static
void
__handle_fav_list_internal
(
const
char
UNUSED
*
key
,
const
char
*
val
,
int
comp
,
void
*
user
)
__handle_fav_list_internal
(
const
char
UNUSED
*
key
,
const
char
*
val
,
int
UNUSED
comp
,
void
*
user
)
{
if
(
comp
)
{
/* Already processed because we only want one line */
if
(
val
)
return
;
}
struct
__uri
*
uri
=
(
struct
__uri
*
)
user
;
uri
->
uri
.
id
=
strtol
(
val
,
NULL
,
0
);
...
...
@@ -575,17 +573,16 @@ __handle_fav_list(struct module_repo_internal *repo, char *fav, size_t fav_size)
}
static
void
__worker_import_favorites_internal
(
const
char
UNUSED
*
k
ey
,
const
char
*
val
,
int
comp
,
void
*
user
)
__worker_import_favorites_internal
(
const
char
UNUSED
*
k
,
const
char
*
val
,
int
UNUSED
c
,
void
*
user
)
{
if
(
comp
)
{
/* Already processed, only want one line of JSON */
if
(
val
==
NULL
)
return
;
}
struct
module_repo_internal
*
repo
=
(
struct
module_repo_internal
*
)
user
;
char
fav
[
LKT_LINE_MAX
];
safe_strncpy
(
fav
,
val
,
LKT_LINE_MAX
);
/* TODO: Add a way to use the workers to do this for each fav list */
LOG_INFO
(
"REPO"
,
"Processing favorite list: %s"
,
fav
);
__handle_fav_list
(
repo
,
fav
,
LKT_LINE_MAX
);
}
...
...
@@ -605,9 +602,8 @@ __worker_import_favorites(void *__repo)
pthread_exit
(
NULL
);
}
LOG_INFO
(
"REPO"
,
"Finished to dl favorite lists"
);
size_t
len
=
json_parse_get_count
(
json
,
1
);
json_parse
(
json
,
1
,
__worker_import_favorites_internal
,
(
void
*
)
repo
);
size_t
len
=
json_parse_get_count
(
json
,
2
);
json_parse
(
json
,
2
,
__worker_import_favorites_internal
,
(
void
*
)
repo
);
free
(
json
);
LOG_INFO
(
"REPO"
,
"Finished to deal with %ld favorite lists"
,
len
);
...
...
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