Wiki source for AthemeMemoServ


Show raw source

==== ""MemoServ"" Module ====
{{lastedit show="3"}}
""MemoServ"" component I wrote for Atheme. I was using the SVN current from the main trunk (Atheme 0.3beta3 [20051003-2531] #16 version tells me).

**General Setup**
~1 Create directories in help and modules

~2 update include/services.h

%%(c)
/* optional services */
struct memosvs
{
char *nick;
char *user;
char *host;
char *real;
char *disp;

service_t *me;
} memosvs;

// later on...
%%

~3 Added the following to include/account.h
%%(c)
/* struct for account memos */
struct mymemo_ {
char sender[NICKLEN];
char text[MEMOLEN];
time_t sent;
uint32_t status;
list_t metadata;
uint8_t newcount;
};

/* memo status flags */
#define MEMO_NEW 0x00000000
#define MEMO_READ 0x00000001
%%

~4 edit src/conf.c to read new conf entries

%%(c)
//line 27 -- definition of sig
static int c_memoserv(CONFIGENTRY *);

//line 82 -- definition of sig
/* MemoServ client information. */
static int c_ms_nick(CONFIGENTRY *);
static int c_ms_user(CONFIGENTRY *);
static int c_ms_host(CONFIGENTRY *);
static int c_ms_real(CONFIGENTRY *);

//line 140 -- table to store conf data in
list_t conf_ms_table;

//line 392 -- add a conf block
add_top_conf("MEMOSERV", c_memoserv);

//line 400 -- add top block of conf item
add_top_conf("MEMOSERV", c_memoserv);

//line 458 -- conf items for parsing
/* memoserv{} block */
add_conf_item("NICK", &conf_ms_table, c_ms_nick);
add_conf_item("USER", &conf_ms_table, c_ms_user);
add_conf_item("HOST", &conf_ms_table, c_ms_host);
add_conf_item("REAL", &conf_ms_table, c_ms_real);

//line 518 -- adds a hook, tells it to read memoserv{} and give it to subblock handler, writing to conf_ms_table
static int c_memoserv(CONFIGENTRY *ce)
{
subblock_handler(ce, &conf_ms_table);
return 0;
}

//line 1141 -- these grab the actual conf values
static int c_ms_nick(CONFIGENTRY *ce)
{
if (ce->ce_vardata == NULL)
PARAM_ERROR(ce);

memosvs.nick = sstrdup(ce->ce_vardata);

return 0;
}

static int c_ms_user(CONFIGENTRY *ce)
{
if (ce->ce_vardata == NULL)
PARAM_ERROR(ce);

memosvs.user = sstrdup(ce->ce_vardata);

return 0;
}

static int c_ms_host(CONFIGENTRY *ce)
{
if (ce->ce_vardata == NULL)
PARAM_ERROR(ce);

memosvs.host = sstrdup(ce->ce_vardata);

return 0;
}

static int c_ms_real(CONFIGENTRY *ce)
{
if (ce->ce_vardata == NULL)
PARAM_ERROR(ce);

memosvs.real = sstrdup(ce->ce_vardata);

return 0;
}
%%

~5 Update modules/Makefile.in

changed SUBDIRS
%%(c)
SUBDIRS = chanserv nickserv global operserv userserv xmlrpc memoserv
%%

This will tell it to recurse into memoserv dir

~6 add to /configure.ac

%%(c)
modules/memoserv/Makefile \
%%

This will tell it to compile based on the makefile in the dir, generated by the configure

~7 Run autoconf
(or autoconf2xx as the case may be). This builds ./configure file

~8 run /.configure

this will build make files

**Module Specific**
~1 Build make files in /modules/memoserv
~2 Write a [[AthemeMemoServMain main.c]]
~3 Added a list_t to includes/account.h to store memos, memo struct in account.h (while putting constant in includes/common.h)
~4 Write other functions - [[AthemeMemoServSend send.c]], [[AthemeMemoServRead read.c]], [[AthemeMemoServList list.c]], [[AthemeMemoServForward forward.c]], [[AthemeMemoServDelete delete.c]]
~5 Build [[AthemeMemoServHelp help.c]] file w/ hookins
~6 [[AthemeMemoServHelp Build help structure]]
~7 Recompile
~8 Add loadmodules to atheme.conf

<< NOTE: your services will NOT join a channel unless it's either explicitly told to (join on config_options.chan) OR you start the services with that services agent! << ::c::

<< HINT: I ended up using make distclean && ./configure && make && make install a lot... Comes in handy, especially when things become strange; shutdown services and run that line and usually things just dissapear << ::c::

----
[[CategoryAtheme]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki