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
1bc1b688
Vérifiée
Valider
1bc1b688
rédigé
Il y a 5 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Reg update
parent
99593911
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!102
Modules
Modifications
4
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
inc/lektor/reg.h
+18
-9
18 ajouts, 9 suppressions
inc/lektor/reg.h
src/main/server.c
+1
-1
1 ajout, 1 suppression
src/main/server.c
src/mkv/mkv.c
+1
-2
1 ajout, 2 suppressions
src/mkv/mkv.c
src/reg.c
+24
-13
24 ajouts, 13 suppressions
src/reg.c
avec
44 ajouts
et
25 suppressions
inc/lektor/reg.h
+
18
−
9
Voir le fichier @
1bc1b688
...
...
@@ -6,14 +6,19 @@ struct lkt_state;
with a name that can be generated or red from a config file. */
struct
module_reg
{
const
char
*
name
;
union
{
void
(
*
func
)(
void
);
void
*
obj
;
};
};
#define REG_EXPORT_NAME "__reg__"
#define REG_BEGIN(reg) struct module_reg reg[] = {
#define REG_ADD(
__f)
{ .name = #
__
f,
.func = (void(*)(void))
__f
},
#define REG_ADD_NAMED(
__
n,
__
f) { .name =
__
n,
.func = (void(*)(void))
__f
},
#define REG_ADD(
f)
{ .name = #f, .func = (void(*)(void))
f
},
#define REG_ADD_NAMED(n, f) { .name = n, .func = (void(*)(void))
f
},
#define REG_END() { .name = NULL, .func = NULL } };
/* Use only once per .so files or you will have some problems... */
#if ! defined(_STATIC_MODULES)
#define REG_EXPORT(__reg) struct module_reg *__reg__ = __reg;
#else
...
...
@@ -29,10 +34,14 @@ void *reg_pick(const char *file, void **handle, const char *symbol);
shared library with REG_EXPORT. Note that this reg is named `__reg__`,
thus no symbol must be named `__reg__` in the .so file.
Returns 0 on success, something else on error. */
int
reg_from_file
(
const
char
*
file
,
struct
module_reg
*
ret
);
int
reg_from_file
(
const
char
*
file
,
struct
module_reg
**
ret
,
void
**
handle
);
/* Set the __reg__ pointer. */
void
reg_export
(
struct
module_reg
*
reg
);
/* Set the ref for this .a / .so file */
void
reg_set
(
struct
module_reg
*
);
/* Get the object named with 'name' from the reg. Returns NULL on error
or 'not found'. */
void
*
__reg_get
(
struct
module_reg
*
reg
,
const
char
*
name
);
/* Load a module by its name. Also initialize the mod pointer. No check on data
type is done, it is up to the user to check if the structure passed as a
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/main/server.c
+
1
−
1
Voir le fichier @
1bc1b688
...
...
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
}
normal_launch:
reg_
s
et
(
server_reg
);
reg_e
xpor
t
(
server_reg
);
mthread_init
();
pthread_create
(
&
th
,
NULL
,
mthread_main
,
NULL
);
if
(
read_self_exe
(
exe
,
PATH_MAX
))
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/mkv/mkv.c
+
1
−
2
Voir le fichier @
1bc1b688
...
...
@@ -608,11 +608,10 @@ kara_read_length(double *len, const char *filename)
}
else
{
if
(
mkv_read_element_length
(
&
file
,
&
elength
)
<
0
)
goto
error
;
if
(
bufferfd_skip
(
&
file
,
elength
)
<
0
)
{
if
(
bufferfd_skip
(
&
file
,
elength
)
<
0
)
goto
error
;
}
}
}
status_code
=
0
;
error:
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/reg.c
+
24
−
13
Voir le fichier @
1bc1b688
...
...
@@ -10,12 +10,27 @@
#include
<strings.h>
#include
<stddef.h>
struct
module_reg
*
reg
;
struct
module_reg
*
__reg__
;
void
reg_export
(
struct
module_reg
*
reg
)
{
__reg__
=
reg
;
}
void
*
reg_
pick
(
const
char
*
file
,
void
**
handle
,
const
char
*
symbol
)
__
reg_
get
(
struct
module_reg
*
reg
,
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
reg
[
i
].
name
&&
reg
[
i
].
func
;
++
i
)
if
(
STR_MATCH
(
reg
[
i
].
name
,
name
))
return
*
(
void
**
)
&
reg
[
i
].
func
;
return
NULL
;
}
void
*
reg_pick
(
const
char
*
file
,
void
**
handle
,
const
char
*
symbol
)
{
if
(
!
symbol
)
return
NULL
;
...
...
@@ -48,17 +63,7 @@ reg_pick(const char *file, void **handle, const char *symbol)
/* Read the reg */
use_reg:
LOG_INFO
(
"REG"
,
"Using the reg structure to find %s"
,
symbol
);
for
(
i
=
0
;
reg
[
i
].
name
&&
reg
[
i
].
func
;
++
i
)
if
(
STR_MATCH
(
reg
[
i
].
name
,
symbol
))
return
*
(
void
**
)
&
reg
[
i
].
func
;
return
NULL
;
}
void
reg_set
(
struct
module_reg
*
_reg
)
{
reg
=
_reg
;
return
__reg_get
(
__reg__
,
symbol
);
}
int
...
...
@@ -104,3 +109,9 @@ load_module_by_name(struct lkt_state *srv, const char *name, void *mod)
return
load_so
(
mod_path
,
mod_load
,
mod
,
srv
);
}
int
reg_from_file
(
const
char
*
file
,
struct
module_reg
**
ret
,
void
**
handle
)
{
*
ret
=
reg_pick
(
file
,
handle
,
REG_EXPORT_NAME
);
return
*
ret
!=
NULL
;
}
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