[NeoStats-Devel] [Commits] r2784 - in trunk: include src
[email protected] Wed, 31 Aug 2005 08:21:39 +1000
| Newsgroups | gmane.comp.neostats.devel |
|---|---|
| Message-ID | <[email protected]> |
Author: Mark
Date: Wed Aug 31 06:21:36 2005
New Revision: 2784
Modified:
trunk/include/neostats.h
trunk/src/commands.c
trunk/src/modules.c
trunk/src/nsevents.c
trunk/src/perl.c
trunk/src/services.c
Log:
reduce code path differences with perl enabled
Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h (original)
+++ trunk/include/neostats.h Wed Aug 31 06:21:36 2005
@@ -870,6 +870,13 @@
#define MODULE_FLAG_AUTH 0x00000001
#define MODULE_FLAG_LOCAL_EXCLUDES 0x00000002
+typedef enum MOD_TYPE {
+ /* standard C Modules */
+ MOD_TYPE_STANDARD = 1,
+ /* Perl Modules */
+ MOD_TYPE_PERL
+} MOD_TYPE;
+
/** @brief Module Info structure
* This describes the module to the NeoStats core and provides information
* to end users when modules are queried.
@@ -924,37 +931,26 @@
typedef int (*mod_auth) ( const Client *u );
+/* Module type macros */
+#define IS_STANDARD_MOD( mod ) ( ( mod )->type == MOD_TYPE_STANDARD )
+#ifdef USE_PERL
+#define IS_PERL_MOD( mod ) ( ( mod )->type == MOD_TYPE_PERL )
+#else /* USE_PERL */
+#define IS_PERL_MOD( mod ) ( 0 )
+#endif /* USE_PERL */
+
#ifdef USE_PERL
-typedef enum MOD_TYPE {
- /* standard C Modules */
- MOD_STANDARD = 1,
- /* Perl Modules */
- MOD_PERL
-} MOD_TYPE;
-
/* forward decleration (in perlmod.h) for perl module info
* we don't include any perl includes here because it screws up
* some of the existing system defines (like readdir) */
struct PerlModInfo;
-
-/* defines to easily detect different modules */
-#define IS_PERL_MOD(mod) ((mod)->modtype == MOD_PERL)
-#define IS_STD_MOD(mod) ((mod)->modtype == MOD_STANDARD)
-
/* to save some chars while typing */
-
#define PMI PerlInterpreter
#endif /* USE_PERL */
-#ifndef USE_PERL
-#define IS_STD_MOD(mod) (1)
-#define IS_PERL_MOD(mod) (0)
-
-#endif /* USE_PERL */
-
#define MODULE_STATUS_SYNCHED 0x00000001
#define MODULE_STATUS_INSYNCH 0x00000002
#define MODULE_STATUS_ERROR 0x00000004
@@ -963,6 +959,8 @@
*
*/
typedef struct _Module {
+ /** type of module */
+ MOD_TYPE type;
/** Pointer to info structure */
ModuleInfo *info;
/** Pointer to event list */
@@ -983,7 +981,6 @@
unsigned int serverdatacnt;
unsigned int channeldatacnt;
#ifdef USE_PERL
- MOD_TYPE modtype;
struct PerlModInfo *pm;
#endif /* USE_PERL */
}_Module;
Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c (original)
+++ trunk/src/commands.c Wed Aug 31 06:21:36 2005
@@ -291,6 +291,7 @@
ns_free(cmd_ptr->cmd);
ns_free(cmd_ptr->moddata);
/* XXX is this correct on a array of strings? */
+ /* Mark: depends on how the array is allocated */
ns_free(cmd_ptr->helptext);
}
#endif
@@ -792,7 +793,7 @@
{
if( cmdparams->bot->moduleptr )
{
- if (IS_STD_MOD(cmdparams->bot->moduleptr))
+ if (IS_STANDARD_MOD(cmdparams->bot->moduleptr))
{
irc_prefmsg_list( cmdparams->bot, cmdparams->source, cmdparams->bot->moduleptr->info->about_text );
#if USE_PERL
@@ -827,7 +828,7 @@
{
if( cmdparams->bot->moduleptr )
{
- if (IS_STD_MOD(cmdparams->bot->moduleptr))
+ if (IS_STANDARD_MOD(cmdparams->bot->moduleptr))
{
irc_prefmsg_list( cmdparams->bot, cmdparams->source,
cmdparams->bot->moduleptr->info->copyright );
Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c (original)
+++ trunk/src/modules.c Wed Aug 31 06:21:36 2005
@@ -124,29 +124,31 @@
int SynchModule( Module* module_ptr )
{
- int err = NS_SUCCESS; /*FAILURE;*/
+ int err = NS_SUCCESS;
int( *ModSynch )( void );
-#ifdef USE_PERL
- /* only standard modules get a sync */
- if( IS_STD_MOD( module_ptr ) ) {
-#endif
- SetModuleInSynch( module_ptr );
+ /* Start sync process */
+ SetModuleInSynch( module_ptr );
+ if( IS_STANDARD_MOD( module_ptr ) )
+ {
ModSynch = ns_dlsym( ( int * ) module_ptr->handle, "ModSynch" );
- if( ModSynch ) {
+ if( ModSynch )
+ {
SET_RUN_LEVEL( module_ptr );
err = ( *ModSynch )();
RESET_RUN_LEVEL();
}
- SET_SEGV_LOCATION();
- SetModuleSynched( module_ptr );
+ }
#ifdef USE_PERL
- } else {
+ else
+ {
SET_RUN_LEVEL( module_ptr );
err = perl_sync_module( module_ptr );
RESET_RUN_LEVEL();
}
#endif
+ /* sync complete */
+ SetModuleSynched( module_ptr );
return err;
}
@@ -313,9 +315,7 @@
mod_ptr->info = infoptr;
mod_ptr->handle = handle;
insert_module( mod_ptr );
-#ifdef USE_PERL
- mod_ptr->modtype = MOD_STANDARD;
-#endif
+ mod_ptr->type = MOD_TYPE_STANDARD;
/* Extract pointer to event list */
eventlistptr = ns_dlsym( handle, "module_events" );
if( eventlistptr ) {
@@ -535,7 +535,7 @@
hash_delete_destroy_node( modulehash, modnode );
/* now determine if its perl, or standard module */
- if( IS_STD_MOD( mod_ptr ) ) {
+ if( IS_STANDARD_MOD( mod_ptr ) ) {
/* call ModFini( replacement for library __fini() call */
ModFini = ns_dlsym( ( int * ) mod_ptr->handle, "ModFini" );
if( ModFini ) {
@@ -573,7 +573,7 @@
DBACloseDatabase();
- if( IS_STD_MOD( mod_ptr ) ) {
+ if( IS_STANDARD_MOD( mod_ptr ) ) {
ns_dlclose( mod_ptr->handle );
#ifdef USE_PERL
} else {
Modified: trunk/src/nsevents.c
==============================================================================
--- trunk/src/nsevents.c (original)
+++ trunk/src/nsevents.c Wed Aug 31 06:21:36 2005
@@ -148,7 +148,7 @@
}
dlog( DEBUG1, "Running module %s with %s", module_ptr->info->name, EventStrings[event] );
SET_SEGV_LOCATION();
- if( IS_STD_MOD( module_ptr ) )
+ if( IS_STANDARD_MOD( module_ptr ) )
{
if( setjmp( sigvbuf ) == 0 )
{
@@ -240,7 +240,7 @@
mod_ptr->event_list = ns_calloc( sizeof( ModuleEvent * ) * EVENT_COUNT );
dlog( DEBUG5, "AddEvent: adding %s to %s", EventStrings[eventptr->event], mod_ptr->info->name );
/* only standard modules have a handler, perl mods use a custom callback */
- if(IS_STD_MOD(mod_ptr) && !eventptr->handler )
+ if(IS_STANDARD_MOD(mod_ptr) && !eventptr->handler )
{
nlog( LOG_ERROR, "AddEvent: missing handler for %s in module %s", EventStrings[eventptr->event], mod_ptr->info->name );
return;
Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c (original)
+++ trunk/src/perl.c Wed Aug 31 06:21:36 2005
@@ -123,9 +123,7 @@
int perl_sync_module(Module *mod)
{
- SetModuleInSynch( mod );
execute_perl (mod, sv_2mortal (newSVpv ("NeoStats::Embed::sync", 0)),1, mod->pm->filename);
- SetModuleSynched( mod );
return NS_SUCCESS;
}
@@ -1547,7 +1545,7 @@
mod = ns_calloc(sizeof(Module));
mod->pm = ns_calloc(sizeof(PerlModInfo));
mod->info = ns_calloc(sizeof(ModuleInfo));
- mod->modtype = MOD_PERL;
+ mod->type = MOD_TYPE_PERL;
strlcpy(mod->pm->filename, filename, MAXPATH);
/* this is a temp solution till we get fully loaded. Its Bad */
mod->info->name = ns_malloc(strlen("NeoStats")+1);
Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c (original)
+++ trunk/src/services.c Wed Aug 31 06:21:36 2005
@@ -90,6 +90,7 @@
/** Fake Module pointer for run level code */
Module ns_module = {
+ MOD_TYPE_STANDARD,
&ns_module_info
};