On 07/11/2012 11:45 AM, Denys Vlasenko wrote:
Hi,
I propose the following attached patches:
Patch 1 removes the wrappers. I don't see why we need them.
Also removes CD_FLAG_FILE, we have CD_FLAG_BIN which is the same.
Patches 2 and 3 simplify save_dump_dir_from_problem_data() code
and the method it uses to pass back the name of the created directory.
Also, move its decl into problem_data.h - I feel it belongs here.
These are pretty mechanical changes, which open up the way for
the next step:
- the API I've created is meant for 3rd party apps which doesn't know
(adn doesn't want to know!!) ABRT/libreport internals that's why I
wanted to unify the naming convention to problem_data_* and that's the
reason why problem_data_save() should be available publicly
- attached example should show how it's meant to be used
$ gcc `pkg-config abrt --cflags --libs` abrt-problem.c
We need to merge create_dump_dir_from_problem_data()
and save_dump_dir_from_problem_data() into one function,
and also reuse this new function instead of open-coded
problem_data -> dump_dir code in abrt-server.
(IOW: we have triple code duplication right now, need to consolidate).
- yes, merging the function would be great and I should have done it
when I was working on the API
#include <libabrt.h>
#include <stdio.h>
int main(int argc, char **argv)
{
problem_data_t *pd = problem_data_new();
problem_data_add_item(pd, "aaa", "bar");
problem_data_add_item(pd, "type", "test");
problem_data_add_item(pd, "analyzer", "test");
problem_data_add_item(pd, "uid", "0");
problem_data_add_item(pd, "executable", "/usr/bin/gnome-terminal");
problem_data_add_file(pd, "/tmp/foo");
char *problem_id = NULL;
LibreportError err = problem_data_save(pd, &problem_id);
if (err != LR_OK) {
printf("Error: '%i'\n", err);
return 1;
}
problem_data_destroy(pd);
printf("'%s'\n", problem_id);
return 0;
}