[pacman-dev] alpm_option_set_logcb(), an example of usage
Hi, I'm developing pyalpm at the moment(new codebase, not related to 2005 pyalpm) and I don't really see any example of usage of alpm_option_set_logcb() on pacman.c file there is alpm_option_set_logcb(cb_log); but I can't find where is cb_log declared, so I have no clue about what does that function do(as I haven't neither found where is the actual code of that function, only that is declared on alpm.h)
On Tue, Aug 12, 2008 at 10:49 PM, Imanol Celaya <archye@pycut.com.ar> wrote:
Hi, I'm developing pyalpm at the moment(new codebase, not related to 2005 pyalpm) and I don't really see any example of usage of alpm_option_set_logcb() on pacman.c file there is alpm_option_set_logcb(cb_log); but I can't find where is cb_log declared, so I have no clue about what does that function do(as I haven't neither found where is the actual code of that function, only that is declared on alpm.h)
Why not just using grep or whatever : $ grep -r cb_log src/pacman/*.c src/pacman/callback.c:void cb_log(pmloglevel_t level, char *fmt, va_list args) src/pacman/pacman.c: alpm_option_set_logcb(cb_log); All callbacks (cb) are defined in that callback.c file.
Why not just using grep or whatever : $ grep -r cb_log src/pacman/*.c src/pacman/callback.c:void cb_log(pmloglevel_t level, char *fmt, va_list args) src/pacman/pacman.c: alpm_option_set_logcb(cb_log);
All callbacks (cb) are defined in that callback.c file.
thanks, I didn't know about grep -r
On Wed, Aug 13, 2008 at 11:17 AM, Imanol Celaya <archye@pycut.com.ar> wrote:
Why not just using grep or whatever : $ grep -r cb_log src/pacman/*.c src/pacman/callback.c:void cb_log(pmloglevel_t level, char *fmt, va_list args) src/pacman/pacman.c: alpm_option_set_logcb(cb_log);
All callbacks (cb) are defined in that callback.c file.
thanks, I didn't know about grep -r
Hmm, in the example above, -r is not needed because I specified a list of files. $ grep cb_log src/pacman/*.c -r is needed when running on directories (just like rm) : $ grep -r cb_log . But sometimes you get unwanted spam, so it is better to only search the .c files like above. Another way : $ find . -name "*.c" | xargs grep logcb Finally, a more powerful tool is cscope : http://cscope.sourceforge.net/ But I didn't manage to get used to this tool yet, I tried it once or twice then I always forget about it :P
On Wed, Aug 13, 2008 at 4:32 AM, Xavier <shiningxc@gmail.com> wrote:
On Wed, Aug 13, 2008 at 11:17 AM, Imanol Celaya <archye@pycut.com.ar> wrote:
Why not just using grep or whatever : $ grep -r cb_log src/pacman/*.c src/pacman/callback.c:void cb_log(pmloglevel_t level, char *fmt, va_list args) src/pacman/pacman.c: alpm_option_set_logcb(cb_log);
All callbacks (cb) are defined in that callback.c file.
thanks, I didn't know about grep -r
Hmm, in the example above, -r is not needed because I specified a list of files. $ grep cb_log src/pacman/*.c
-r is needed when running on directories (just like rm) : $ grep -r cb_log .
But sometimes you get unwanted spam, so it is better to only search the .c files like above. Another way : $ find . -name "*.c" | xargs grep logcb
Finally, a more powerful tool is cscope : http://cscope.sourceforge.net/ But I didn't manage to get used to this tool yet, I tried it once or twice then I always forget about it :P
ctags is great as well. ctags -R will build the tag database, and then I could type: vim -t cb_log and it would bring me right to the function without even knowing what file it is in. -Dan
On Wed, Aug 13, 2008 at 12:51 PM, Dan McGee <dpmcgee@gmail.com> wrote:
ctags is great as well. ctags -R will build the tag database, and then I could type: vim -t cb_log and it would bring me right to the function without even knowing what file it is in.
Uh yeah, I should definitively have mentioned that, I use ctags all the time. It is probably what I would have used in this case. I would have opened pacman.c in vim, browsing the code, find this line : alpm_option_set_logcb(cb_log); Then I put the cursor and cb_log, press Ctrl+] , and it goes directly to the function. And Ctrl+T to go back. But thanks for the "vim -t" way, I didn't know that one :)
On 13/08/2008, at 4:49 AM, Imanol Celaya wrote:
Hi, I'm developing pyalpm at the moment(new codebase, not related to 2005 pyalpm) and I don't really see any example of usage of alpm_option_set_logcb() on pacman.c file there is alpm_option_set_logcb(cb_log); but I can't find where is cb_log declared, so I have no clue about what does that function do(as I haven't neither found where is the actual code of that function, only that is declared on alpm.h) _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
Not sure if you'll find this useful, but I have been working on an Objective-C wrapper for libalpm: http://github.com/sebnow/packagemanager It's not finished, but it does have some documentation that you might find useful.
participants (4)
-
Dan McGee
-
Imanol Celaya
-
Sebastian Nowicki
-
Xavier