summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--channels.c2
-rwxr-xr-xconfigure6
-rw-r--r--modules.c156
-rw-r--r--modules.h7
-rw-r--r--services.h1
-rw-r--r--version.log7
7 files changed, 161 insertions, 19 deletions
diff --git a/Changes b/Changes
index 0741dee58..1a17c1148 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
Anope Version S V N
-------------------
Provided by Anope Dev. <dev@anope.org> - 2004
+06/22 F Changed strcasecmp to stricmp as it should be [ #00]
06/20 F PTLink server support [ #00]
06/18 A Added proper Bahamut1.8 support. [ #55]
diff --git a/channels.c b/channels.c
index 9e51ba9e6..dce7e5460 100644
--- a/channels.c
+++ b/channels.c
@@ -1457,7 +1457,7 @@ static void del_exception(Channel * chan, char *mask)
int reset = 0;
for (i = 0; i < chan->exceptcount; i++) {
- if ((!reset) && (strcasecmp(chan->excepts[i], mask) == 0)) {
+ if ((!reset) && (stricmp(chan->excepts[i], mask) == 0)) {
free(chan->excepts[i]);
reset = 1;
}
diff --git a/configure b/configure
index 1a61b34c6..708db1788 100755
--- a/configure
+++ b/configure
@@ -710,6 +710,12 @@ if [ "$USE_MODULES" = "USE_MODULES" ] ; then
ok=1
fi
fi
+ if [ ! -d "$INPUT/data/" ] ; then
+ if mkdir -p $INPUT/data/ ; then
+ ok=1
+ fi
+ fi
+
done
MODULE_PATH=$INPUT
echo ""
diff --git a/modules.c b/modules.c
index 99b40bc49..eab5c0f73 100644
--- a/modules.c
+++ b/modules.c
@@ -185,7 +185,7 @@ int addModule(Module * m)
index = CMD_HASH(m->name);
for (current = MODULE_HASH[index]; current; current = current->next) {
- if (strcasecmp(m->name, current->name) == 0)
+ if (stricmp(m->name, current->name) == 0)
return MOD_ERR_EXISTS;
lastHash = current;
}
@@ -223,7 +223,7 @@ int delModule(Module * m)
index = CMD_HASH(m->name);
for (current = MODULE_HASH[index]; current; current = current->next) {
- if (strcasecmp(m->name, current->name) == 0) {
+ if (stricmp(m->name, current->name) == 0) {
if (!lastHash) {
MODULE_HASH[index] = current->next;
} else {
@@ -749,7 +749,7 @@ int moduleDelCommand(CommandHash * cmdTable[], char *name)
for (cmd = c; cmd; cmd = cmd->next) {
if (cmd->mod_name
- && strcasecmp(cmd->mod_name, mod_current_module->name) == 0) {
+ && stricmp(cmd->mod_name, mod_current_module->name) == 0) {
if (debug) {
displayCommandFromHash(cmdTable, name);
}
@@ -778,7 +778,7 @@ int displayCommandFromHash(CommandHash * cmdTable[], char *name)
alog("trying to display command %s", name);
}
for (current = cmdTable[index]; current; current = current->next) {
- if (strcasecmp(name, current->name) == 0) {
+ if (stricmp(name, current->name) == 0) {
displayCommand(current->c);
}
}
@@ -822,7 +822,7 @@ int displayMessageFromHash(char *name)
alog("trying to display message %s", name);
}
for (current = IRCD[index]; current; current = current->next) {
- if (strcasecmp(name, current->name) == 0) {
+ if (stricmp(name, current->name) == 0) {
displayMessage(current->m);
}
}
@@ -881,7 +881,7 @@ int addCommand(CommandHash * cmdTable[], Command * c, int pos)
&& (!strcmp(c->service, current->c->service) == 0)) {
continue;
}
- if ((strcasecmp(c->name, current->name) == 0)) { /* the cmd exist's we are a addHead */
+ if ((stricmp(c->name, current->name) == 0)) { /* the cmd exist's we are a addHead */
if (pos == 1) {
c->next = current->c;
current->c = c;
@@ -940,7 +940,7 @@ int delCommand(CommandHash * cmdTable[], Command * c, char *mod_name)
index = CMD_HASH(c->name);
for (current = cmdTable[index]; current; current = current->next) {
- if (strcasecmp(c->name, current->name) == 0) {
+ if (stricmp(c->name, current->name) == 0) {
if (!lastHash) {
tail = current->c;
if (tail->next) {
@@ -1089,7 +1089,7 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos)
index = CMD_HASH(m->name);
for (current = msgTable[index]; current; current = current->next) {
- if (strcasecmp(m->name, current->name) == 0) { /* the msg exist's we are a addHead */
+ if (stricmp(m->name, current->name) == 0) { /* the msg exist's we are a addHead */
if (pos == 1) {
m->next = current->m;
current->m = m;
@@ -1220,7 +1220,7 @@ int delMessage(MessageHash * msgTable[], Message * m, char *mod_name)
index = CMD_HASH(m->name);
for (current = msgTable[index]; current; current = current->next) {
- if (strcasecmp(m->name, current->name) == 0) {
+ if (stricmp(m->name, current->name) == 0) {
if (!lastHash) {
tail = current->m;
if (tail->next) {
@@ -1755,13 +1755,17 @@ void moduleDisplayHelp(int service, User * u)
/**
* Add module data to a struct.
- * This allows module coders to add data to an existing struct
+ * This actaully adds the request data to the moduleData structs, this should not be called directly from modules.
* @param md The module data for the struct to be used
* @param key The Key for the key/value pair
* @param value The value for the key/value pair, this is what will be stored for you
+ * @param persistant Should the key/value pair be persistant?
* @return MOD_ERR_OK will be returned on success
+ * @see moduleAddData
+ * @see moduleAddPersistantData
**/
-int moduleAddData(ModuleData * md[], char *key, char *value)
+int moduleAddDataValue(ModuleData * md[], char *key, char *value,
+ int persistant)
{
char *mod_name = sstrdup(mod_current_module_name);
@@ -1780,7 +1784,7 @@ int moduleAddData(ModuleData * md[], char *key, char *value)
}
for (current = md[index]; current; current = current->next) {
- if (strcasecmp(current->moduleName, mod_name) == 0)
+ if (stricmp(current->moduleName, mod_name) == 0)
lastHash = current;
}
@@ -1801,7 +1805,7 @@ int moduleAddData(ModuleData * md[], char *key, char *value)
**/
for (itemCurrent = lastHash->di; itemCurrent;
itemCurrent = itemCurrent->next) {
- if (strcasecmp(itemCurrent->key, key) == 0) {
+ if (stricmp(itemCurrent->key, key) == 0) {
item = itemCurrent;
}
lastItem = itemCurrent;
@@ -1813,6 +1817,7 @@ int moduleAddData(ModuleData * md[], char *key, char *value)
}
item->next = NULL;
item->key = strdup(key);
+ item->persistant = persistant;
item->value = strdup(value);
if (lastItem)
lastItem->next = item;
@@ -1830,6 +1835,32 @@ int moduleAddData(ModuleData * md[], char *key, char *value)
}
/**
+ * Add persistant module data to a struct.
+ * This allows module coders to add data to an existing struct, and have anope take care of loading/saving it!
+ * @param md The module data for the struct to be used
+ * @param key The Key for the key/value pair
+ * @param value The value for the key/value pair, this is what will be stored for you
+ * @return MOD_ERR_OK will be returned on success
+ **/
+int moduleAddPersistantData(ModuleData * md[], char *key, char *value)
+{
+ return moduleAddDataValue(md, key, value, 1);
+}
+
+/**
+ * Add module data to a struct.
+ * This allows module coders to add data to an existing struct
+ * @param md The module data for the struct to be used
+ * @param key The Key for the key/value pair
+ * @param value The value for the key/value pair, this is what will be stored for you
+ * @return MOD_ERR_OK will be returned on success
+ **/
+int moduleAddData(ModuleData * md[], char *key, char *value)
+{
+ return moduleAddDataValue(md, key, value, 0);
+}
+
+/**
* Returns the value from a key/value pair set.
* This allows module coders to retrive any data they have previuosly stored in any given struct
* @param md The module data for the struct to be used
@@ -1847,7 +1878,7 @@ char *moduleGetData(ModuleData * md[], char *key)
index = CMD_HASH(mod_name);
for (current = md[index]; current; current = current->next) {
- if (strcasecmp(current->moduleName, mod_name) == 0)
+ if (stricmp(current->moduleName, mod_name) == 0)
lastHash = current;
}
@@ -1882,7 +1913,7 @@ void moduleDelData(ModuleData * md[], char *key)
index = CMD_HASH(mod_name);
for (current = md[index]; current; current = current->next) {
- if (strcasecmp(current->moduleName, mod_name) == 0)
+ if (stricmp(current->moduleName, mod_name) == 0)
lastHash = current;
}
if (lastHash) {
@@ -1925,7 +1956,7 @@ void moduleDelAllData(ModuleData * md[])
index = CMD_HASH(mod_name);
for (current = md[index]; current; current = current->next) {
- if (strcasecmp(current->moduleName, mod_name) == 0)
+ if (stricmp(current->moduleName, mod_name) == 0)
lastHash = current;
}
if (lastHash) {
@@ -2026,4 +2057,97 @@ void moduleCleanStruct(ModuleData * moduleData[])
}
}
+/**
+ * Load any data relevant for this module
+ * @param m The module to Load the data for
+ **/
+void moduleLoadAllData(Module * m)
+{
+ FILE *in;
+ char buffer[2000]; /* will _never_ be this big thanks to the 512 limit of a message */
+ char filename[4096];
+ char *key = NULL;
+ char *value = NULL;
+ char *service = NULL;
+ char *str_key = NULL;
+ int len;
+ enum MODULE_DATA_TYPE struc;
+ NickCore *nc;
+ NickAlias *na;
+ Channel *c;
+
+ strncpy(filename, MODULE_PATH, 4095);
+ len = strlen(filename);
+ strncat(filename, "data/", 4095 - len);
+ len = strlen(filename);
+ strncat(filename, m->name, 4095 - len);
+ len = strlen(filename);
+ strncat(filename, ".db", 4095 - len);
+
+ if ((in = fopen(filename, "r")) == NULL) {
+ alog("unable to open module data file [%s] for reading, module data will not be loaded", filename);
+ } else {
+ while (!feof(in)) {
+ fgets(buffer, 1500, in);
+ service = myStrGetToken(buffer, ' ', 0);
+ str_key = myStrGetToken(buffer, ' ', 1);
+ key = myStrGetToken(buffer, ' ', 2);
+ value = myStrGetTokenRemainder(buffer, ' ', 3);
+ if (service) {
+ struc = atoi(service);
+ if (str_key) {
+ if (key) {
+ if (value) {
+ switch (struc) {
+ case MD_NICK_CORE:
+ nc = findcore(str_key);
+ if (nc) {
+ moduleAddPersistantData(nc->moduleData,
+ key, value);
+ }
+ break;
+ case MD_NICK_ALIAS:
+ na = findnick(str_key);
+ if (na) {
+ moduleAddPersistantData(na->moduleData,
+ key, value);
+ }
+ break;
+ case MD_NICK_MEMO:
+
+ break;
+ case MD_CHAN_MEMO:
+
+ break;
+ case MD_CHAN_INFO:
+ c = findchan(name);
+ if (c && c->ci) {
+ moduleAddPersistantData(c->ci->
+ moduleData,
+ key, value);
+ }
+ break;
+ }
+ free(value);
+ }
+ free(key);
+ }
+ free(str_key);
+ }
+ free(service);
+ }
+ }
+ }
+}
+
+/**
+ * Save any data relevant for this module
+ * @param m The module to Save the data for
+ **/
+void moduleSaveAllData(Module * m)
+{
+
+}
+
+
/* EOF */
diff --git a/modules.h b/modules.h
index 732f1e1bf..aaa4181a9 100644
--- a/modules.h
+++ b/modules.h
@@ -74,6 +74,8 @@ extern CommandHash *HELPSERV[MAX_CMD_HASH];
extern CommandHash *OPERSERV[MAX_CMD_HASH];
extern MessageHash *IRCD[MAX_CMD_HASH];
+enum MODULE_DATA_TYPE { MD_NICK_CORE = 1, MD_NICK_ALIAS = 2, MD_NICK_MEMO = 3, MD_CHAN_MEMO =4, MD_CHAN_INFO = 5};
+
struct Module_ {
char *name;
char *filename;
@@ -221,12 +223,15 @@ void moduleDelCallback(char *name);
void moduleCallBackRun(void);
char *moduleGetData(ModuleData *md[], char *key); /* Get the value for this key from this struct */
+int moduleAddDataValue(ModuleData * md[], char *key, char *value,int persistant); /* Store the value in the struct */
+int moduleAddPersistantData(ModuleData * md[], char *key, char *value); /* Set the value for this key for this struct to be saved*/
int moduleAddData(ModuleData *md[], char *key, char *value); /* Set the value for this key for this struct */
void moduleDelData(ModuleData *md[], char *key); /* Delete this key/value pair */
void moduleDelAllData(ModuleData *md[]); /* Delete all key/value pairs for this module for this struct */
void moduleCleanStruct(ModuleData * moduleData[]); /* Clean a moduleData hash */
void moduleDelAllDataMod(Module *m); /* remove all module data from all structs for this module */
-
+void moduleLoadAllData(Module *m); /* Load any persistant module data settings */
+void moduleSaveAllData(Module *m); /* Save any persistant module data settings */
/*************************************************************************/
#endif
diff --git a/services.h b/services.h
index 6033673a0..62e7d2aa9 100644
--- a/services.h
+++ b/services.h
@@ -424,6 +424,7 @@ struct ModuleDataItem_ {
char *key; /* The key */
char *value; /* The Value */
ModuleDataItem *next; /* The next ModuleDataItem in this list */
+ int persistant; /* Is this value persistant? */
};
struct ModuleData_ {
diff --git a/version.log b/version.log
index d199db171..7bb7d93eb 100644
--- a/version.log
+++ b/version.log
@@ -8,10 +8,15 @@
VERSION_MAJOR="1"
VERSION_MINOR="7"
VERSION_PATCH="4"
-VERSION_BUILD="209"
+VERSION_BUILD="210"
# $Log$
#
+# BUILD : 1.7.4 (210)
+# BUGS : N/A
+# NOTES : Changed strcasecmp to stricmp
+#
+#
# BUILD : 1.7.4 (209)
# BUGS : none
# NOTES : Fixed implementation for dynamic server /OS GLOBAL