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 *======================================================================*/
25 #include "queue_msg.h"
26 #include "queue_mqueue.h"
34 #include <dlfcn.h> // see http://www.tldp.org/HOWTO/C++-dlopen/index.html
36 int queue_factory (struct queue
* this_queue
)
38 /* Create queue object. */
39 if ( strcmp(arg_queue_type
, ARG_MSG
) == 0 )
41 if ( queue_msg_ctor(this_queue
, arg_queue_name
,
42 arg_queue_max_sz
, arg_queue_max_cnt
) < 0 )
44 LOG_ER("No SysV SHM support.\n");
48 else if ( strcmp(arg_queue_type
, ARG_MQ
) == 0 )
50 if ( queue_mqueue_ctor(this_queue
, arg_queue_name
,
51 arg_queue_max_sz
, arg_queue_max_cnt
) < 0 )
53 LOG_ER("No POSIX mqueue support.\n");
62 strcpy(pathname
, "/home/y/lib/liblwes-journaller-queue-") ;
63 strcat(pathname
, arg_queue_type
) ;
64 strcat(pathname
, ".so") ;
65 module
= dlopen(pathname
, RTLD_NOW
) ;
70 strcpy(symname
, "lwes_journaller_queue_") ;
71 strcat(symname
, arg_queue_type
) ;
72 strcat(symname
, "_LTX_init") ;
73 lwes_journaller_queue_init_t init
=
74 (lwes_journaller_queue_init_t
) dlsym(module
, symname
) ;
77 if ( (*init
)(this_queue
, arg_queue_name
,
78 arg_queue_max_sz
, arg_queue_max_cnt
) < 0 )
80 LOG_ER("Failed to create a dynamic queue method.\n") ;
97 LOG_ER("Unrecognized queue type '%s', try \"" ARG_MSG
"\" or "
98 "\"" ARG_MQ
"\".\n%s\n", arg_queue_type
, err
);