+ /* XXX duplicated code :( */
+ if(mheader->mapi_register && (mheader->mapi_register() == -1))
+ {
+ ilog(L_MAIN, "Module %s indicated failure during load.",
+ mod_basename);
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "Module %s indicated failure during load.",
+ mod_basename);
+ lt_dlclose(tmpptr);
+ rb_free(mod_basename);
+ return -1;
+ }
+
+ /* Basic date code checks
+ *
+ * Don't make them fatal, but do complain about differences within a certain time frame.
+ * Later on if there are major API changes we can add fatal checks.
+ * -- Elizafox
+ */
+ if(mheader->mapi_datecode != datecode && mheader->mapi_datecode > 0)
+ {
+ long int delta = datecode - mheader->mapi_datecode;
+ if (delta > MOD_WARN_DELTA)
+ {
+ delta /= 86400;
+ iwarn("Module %s build date is out of sync with ircd build date by %ld days, expect problems",
+ mod_basename, delta);
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "Module %s build date is out of sync with ircd build date by %ld days, expect problems",
+ mod_basename, delta);
+ }
+ }
+
+ if(mheader->mapi_command_list)
+ {
+ struct Message **m;
+ for (m = mheader->mapi_command_list; *m; ++m)
+ mod_add_cmd(*m);
+ }
+
+ if(mheader->mapi_hook_list)
+ {
+ mapi_hlist_av1 *m;
+ for (m = mheader->mapi_hook_list; m->hapi_name; ++m)
+ *m->hapi_id = register_hook(m->hapi_name);
+ }
+
+ if(mheader->mapi_hfn_list)
+ {
+ mapi_hfn_list_av1 *m;
+ for (m = mheader->mapi_hfn_list; m->hapi_name; ++m)
+ add_hook(m->hapi_name, m->fn);
+ }
+
+ /* New in MAPI v2 - version replacement */
+ ver = mheader->mapi_module_version ? mheader->mapi_module_version : ircd_version;
+ description = mheader->mapi_module_description;
+
+ if(mheader->mapi_cap_list)
+ {
+ mapi_cap_list_av2 *m;
+ for (m = mheader->mapi_cap_list; m->cap_name; ++m)
+ {
+ struct CapabilityIndex *idx;
+ int result;
+
+ switch (m->cap_index)
+ {
+ case MAPI_CAP_CLIENT:
+ idx = cli_capindex;
+ break;
+ case MAPI_CAP_SERVER:
+ idx = serv_capindex;
+ break;
+ default:
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "Unknown/unsupported CAP index found of type %d on capability %s when loading %s",
+ m->cap_index, m->cap_name, mod_basename);
+ ilog(L_MAIN,
+ "Unknown/unsupported CAP index found of type %d on capability %s when loading %s",
+ m->cap_index, m->cap_name, mod_basename);
+ continue;
+ }
+
+ result = capability_put(idx, m->cap_name, m->cap_ownerdata);
+ if (m->cap_id != NULL)
+ *(m->cap_id) = result;
+ }
+ }
+ }
+
+ break;