1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
23 #include "journal_gz.h"
24 #include "journal_file.h"
32 #include <dlfcn.h> /* see http://www.tldp.org/HOWTO/C++-dlopen/index.html */
34 int journal_factory(struct journal
* jrn
, const char* name
)
36 if ( strcmp(arg_journ_type
, ARG_FILE
) == 0 )
38 if ( journal_file_ctor(jrn
, name
) < 0 )
40 LOG_ER("Failed to create a plain file journal.\n");
44 else if ( strcmp(arg_journ_type
, ARG_GZ
) == 0 )
46 if ( journal_gz_ctor(jrn
, name
) < 0 )
48 LOG_ER("Failed to create a GZ compressed journal.\n");
57 /* TODO: Change /home/y/lib */
58 strcpy(pathname
, "/home/y/lib/liblwes-journaller-journal-") ;
59 strcat(pathname
, arg_journ_type
) ;
60 strcat(pathname
, ".so") ;
61 module
= dlopen(pathname
, RTLD_NOW
) ;
66 strcpy(symname
, "lwes_journaller_journal_") ;
67 strcat(symname
, arg_journ_type
) ;
68 strcat(symname
, "_LTX_init") ;
69 lwes_journaller_journal_init_t init
=
70 (lwes_journaller_journal_init_t
) dlsym(module
, symname
) ;
73 if ( (*init
)(jrn
, name
) < 0 )
75 LOG_ER("Failed to create a dynamic journal method.\n") ;
93 LOG_ER("Unrecognized journal type \"%s\", try \"" ARG_FILE
"\" or \"" ARG_GZ
"\".\n%s\n",