52 char timestamp[18], telem[5];
56 memset(&tm, 0,
sizeof(
struct tm));
61 if((ret = storage_get(mod->
mm->
sm->
st,
"motd-message", domain, NULL, &os)) == st_SUCCESS) {
62 if(os_iter_first(os)) {
63 o = os_iter_object(os);
64 if(os_object_get_nad(os, o,
"xml", &nad)) {
73 telem[0] = timestamp[0];
74 telem[1] = timestamp[1];
75 telem[2] = timestamp[2];
76 telem[3] = timestamp[3];
78 tm.tm_year = atoi(telem) - 1900;
81 telem[0] = timestamp[4];
82 telem[1] = timestamp[5];
84 tm.tm_mon = atoi(telem) - 1;
87 telem[0] = timestamp[6];
88 telem[1] = timestamp[7];
89 tm.tm_mday = atoi(telem);
92 telem[0] = timestamp[9];
93 telem[1] = timestamp[10];
94 tm.tm_hour = atoi(telem);
97 telem[0] = timestamp[12];
98 telem[1] = timestamp[13];
99 tm.tm_min = atoi(telem);
102 telem[0] = timestamp[15];
103 telem[1] = timestamp[16];
104 tm.tm_sec = atoi(telem);
106 data->
t = timegm(&tm);
114 if(data->
tos != NULL)
116 data->
tos = os_new();
117 os_object_put(os_object_new(data->
tos),
"time", &data->
t, os_type_INTEGER);
130 if(data->
nad == NULL) {
134 if(data->
nad == NULL)
142 storage_get(sess->
user->
sm->
st,
"motd-times",
jid_user(sess->
jid), NULL, &os) == st_SUCCESS) {
143 if(os_iter_first(os)) {
144 o = os_iter_object(os);
145 os_object_get_time(os, o,
"time", &t);
181 for(sess = user->
sessions; sess != NULL; sess = sess->
next) {
249 store =
pkt_dup(pkt, NULL, NULL);
255 o = os_object_new(os);
257 os_object_put(o,
"xml", store->nad, os_type_NAD);
260 ret = storage_replace(mod->
mm->
sm->
st,
"motd-message", pkt->
to->
domain, NULL, os);
277 if(data->
nad != NULL)
279 data->
nad = store->nad;
286 if(data->
tos != NULL)
288 data->
tos = os_new();
289 os_object_put(os_object_new(data->
tos),
"time", &t, os_type_INTEGER);
292 else if(strcmp(&(pkt->
to->
resource[8]),
"/online") != 0) {
315 storage_delete(mi->
sm->
st,
"motd-times",
jid_user(jid), NULL);
322 if(data->
tos != NULL) os_free(data->
tos);
330 if(mod->
init)
return 0;
user_t user
user this session belongs to
pkt_type_t type
packet type
jid_t jid
session jid (user@host/res)
data structures and prototypes for the session manager
static mod_ret_t _announce_pkt_sm(mod_instance_t mi, pkt_t pkt)
DLLEXPORT int module_init(mod_instance_t mi, const char *arg)
int pri
current priority of this session
const char * jid_user(jid_t jid)
expand and return the user
const char * jid_full(jid_t jid)
expand and return the full
jid_t jid_new(const char *id, int len)
make a new jid
int nad_find_attr(nad_t nad, unsigned int elem, int ns, const char *name, const char *val)
get a matching attr on this elem, both name and optional val
single instance of a module in a chain
void nad_set_attr(nad_t nad, unsigned int elem, int ns, const char *name, const char *val, int vallen)
create, update, or zap any matching attr on this elem
void nad_drop_elem(nad_t nad, unsigned int elem)
remove an element (and its subelements)
int init
number of times the module intialiser has been called
#define stanza_err_FEATURE_NOT_IMPLEMENTED
pkt_t pkt_dup(pkt_t pkt, const char *to, const char *from)
duplicate pkt, replacing addresses
#define stanza_err_FORBIDDEN
void nad_free(nad_t nad)
free that nad
nad_t nad_copy(nad_t nad)
copy a nad
xht users
pointers to currently loaded users (key is user@domain)
sess_t next
next session (in a list of sessions)
pkt_t pkt_new(sm_t sm, nad_t nad)
sess_t top
top priority session
mod_ret_t(* in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
in-sess handler
static void _announce_user_delete(mod_instance_t mi, jid_t jid)
jid_t jid_reset_components(jid_t jid, const char *node, const char *domain, const char *resource)
build a jid from components
sess_t sessions
list of action sessions
module_t mod
module that this is an instance of
jid_t from
packet addressing (not used for routing)
static mod_ret_t _announce_in_sess(mod_instance_t mi, sess_t sess, pkt_t pkt)
void * private
module private data
packet summary data wrapper
storage_t st
storage subsystem
nad_t nad
nad of the entire packet
void jid_free(jid_t jid)
free a jid
int aci_check(xht aci, const char *type, const char *name)
see if a username is in an acl
void pkt_router(pkt_t pkt)
packet was unhandled, should be passed to the next module
packet was handled (and freed)
There is one instance of this struct per user who is logged in to this c2s instance.
struct moddata_st * moddata_t
int nad_find_elem(nad_t nad, unsigned int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
void xhash_walk(xht h, xhash_walker w, void *arg)
static void _announce_free(module_t mod)
void(* user_delete)(mod_instance_t mi, jid_t jid)
user-delete handler
mod_ret_t(* pkt_sm)(mod_instance_t mi, pkt_t pkt)
pkt-sm handler
int available
true if this session is available
void pkt_delay(pkt_t pkt, time_t t, const char *from)
add an x:delay stamp
jid_t jid
user jid (user@host)
xht acls
access control lists (key is list name, value is jid_t list)
void(* free)(module_t mod)
called when module is freed
void ** module_data
per-user module data
pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
mod_ret_t
module return values
static void _announce_load(module_t mod, moddata_t data, const char *domain)
static void _announce_broadcast_user(const char *key, int keylen, void *val, void *arg)
#define stanza_err_INTERNAL_SERVER_ERROR
int nad_find_scoped_namespace(nad_t nad, const char *uri, const char *prefix)
find a namespace in scope