Bonjour,
J'utilise une libraire écrite en C
Alors j'ai deux problèmes j'ai une function :
Je l'ai redéfini :Code:
1
2 int pacman_set_option(unsigned char parm, unsigned long data);
Code:
1
2
3
4
5
6 def pacman_set_option(parm,data): print_debug("pacman_set_option") pacman.pacman_set_option.argtypes = [ctypes.c_int,ctypes.c_long] pacman.pacman_set_option.restype = ctypes.c_int return pacman.pacman_set_option(parm,data)
à data je peux lui passer le nom d'un function pour un callback
par exemple en C :
ou une chaine qui peux contenir le nom d'un paquet à chercher comme python :)Code:
1
2
3
4
5
6
7
8 static void _log_cb (unsigned short level, char *msg) { g_print ("%s\n", msg); return; } ... pacman_set_option (PM_OPT_LOGCB, (long)_log_cb);
Comment convertir le nom d'une fonction vers le pointeur de cette fonction et une chaine en (long)Code:
1
2 pacman_set_option (PM_OPT_NEEDLES, (long)search_str);
Le code complet est disponible ici : http://dors.frugalware.org/tmpgit/fr...n/py-pacman.py
et le .h si besoin est la : http://git.frugalware.org/gitweb/git...528904;hb=HEAD
Merci à qui aura une idée :)
(j'espere avoir été clair)