diff mcabber/src/compl.c @ 1607:14690e624e9d

Add modules
author Myhailo Danylenko <isbear@ukrpost.net>
date Sun, 11 Oct 2009 16:01:52 +0200
parents dcd5d4c75199
children
line wrap: on
line diff
--- a/mcabber/src/compl.c	Sun Oct 11 16:01:31 2009 +0200
+++ b/mcabber/src/compl.c	Sun Oct 11 16:01:52 2009 +0200
@@ -53,6 +53,44 @@
 static GSList *Categories;
 static compl *InputCompl;
 
+#ifdef MODULES_ENABLE
+guint registered_cats = COMPL_CMD|COMPL_JID|COMPL_URLJID|COMPL_NAME| \
+                        COMPL_STATUS|COMPL_FILENAME|COMPL_ROSTER|COMPL_BUFFER| \
+                        COMPL_GROUP|COMPL_GROUPNAME|COMPL_MULTILINE|COMPL_ROOM| \
+                        COMPL_RESOURCE|COMPL_AUTH|COMPL_REQUEST|COMPL_EVENTS| \
+                        COMPL_EVENTSID|COMPL_PGP|COMPL_COLOR| \
+                        COMPL_OTR|COMPL_OTRPOLICY| \
+                        0;
+
+//  compl_new_category()
+// Reserves id for new completion category.
+// Returns 0, if no more categories can be allocated.
+// Note, that user should not make any assumptions about id nature,
+// as it is likely to change in future.
+guint compl_new_category (void)
+{
+  guint i = 0;
+  while ((registered_cats >> i) & 1)
+    i++;
+  if (i >= sizeof (guint)*8)
+    return 0;
+  else {
+    guint id = 1 << i;
+    registered_cats |= id;
+    return id;
+  }
+}
+
+//  compl_del_category (id)
+// Frees reserved id for category.
+// Note, that for now it not validates its input, so, be careful
+// and specify exactly what you get from compl_new_category.
+void compl_del_category (guint id)
+{
+  registered_cats &= ~id;
+}
+#endif
+
 //  new_completion(prefix, compl_cat)
 // . prefix    = beginning of the word, typed by the user
 // . compl_cat = pointer to a completion category list (list of *char)