Przeglądaj źródła

* Hacked out notes.mod

svn: 652
Bryan Drewery 22 lat temu
rodzic
commit
b73a5a5f95
6 zmienionych plików z 41 dodań i 57 usunięć
  1. 1 1
      src/botmsg.c
  2. 1 1
      src/main.c
  3. 29 33
      src/mod/notes.mod/notes.c
  4. 9 8
      src/mod/notes.mod/notes.h
  5. 1 6
      src/mod/static.h
  6. 0 8
      src/modules.c

+ 1 - 1
src/botmsg.c

@@ -20,6 +20,7 @@
 #include "botnet.h"
 #include "tandem.h"
 #include "core_binds.h"
+#include "src/mod/notes.mod/notes.h"
 #include <stdarg.h>
 
 extern struct dcc_t	*dcc;
@@ -561,7 +562,6 @@ void botnet_send_nkch_part(int butidx, int useridx, char *oldnick)
 /* This part of add_note is more relevant to the botnet than
  * to the notes file
  */
-extern int (*storenote)(char *from, char *to, char *msg, int idx, char *who, int bufsize);
 int add_note(char *to, char *from, char *msg, int idx, int echo)
 {
   int status, i, iaway, sock;

+ 1 - 1
src/main.c

@@ -1207,7 +1207,7 @@ int main(int argc, char **argv)
   module_load("transfer");
   module_load("share");
   update_init();
-  module_load("notes");
+  notes_init();
   console_init();
   ctcp_init();
   module_load("compress");

+ 29 - 33
src/mod/notes.mod/notes.c

@@ -7,15 +7,29 @@
  *
  */
 
-#define MODULE_NAME "notes"
-#define MAKING_NOTES
-#include <fcntl.h>
-#include <sys/stat.h> /* chmod(..) */
-#include "src/mod/module.h"
+#undef MAKING_MODS
+#include "notes.h"
+#include "src/common.h"
+#include "src/chanprog.h"
+#include "src/botnet.h"
+#include "src/userrec.h"
+#include "src/userent.h"
+#include "src/misc_file.h"
+#include "src/modules.h"
+#include "src/misc.h"
+#include "src/users.h"
+
 #include "src/tandem.h"
+#include "src/tclhash.h"
 #include "src/botmsg.h" /* NOTE DEFINES */
-#undef global
-#include "notes.h"
+
+#include <fcntl.h>
+#include <sys/stat.h> /* chmod(..) */
+
+extern struct userrec	*userlist;
+extern time_t now;
+extern char botnetnick[];
+extern int userfile_perm;
 
 static int maxnotes = 50;	/* Maximum number of notes to allow stored
 				 * for each user */
@@ -23,7 +37,6 @@ static int note_life = 60;	/* Number of DAYS a note lives */
 static char notefile[121] = ".n";	/* Name of the notefile */
 static int allow_fwd = 1;	/* Allow note forwarding */
 static int notify_users = 1;	/* Notify users they have notes every hour? */
-static Function *global = NULL;	/* DAMN fcntl.h */
 
 static struct user_entry_type USERENTRY_FWD =
 {
@@ -43,7 +56,7 @@ static struct user_entry_type USERENTRY_FWD =
 #include "cmdsnote.c"
 
 
-static void fwd_display(int idx, struct user_entry *e, struct userrec *u)
+void fwd_display(int idx, struct user_entry *e, struct userrec *u)
 {
   if (dcc[idx].user && (dcc[idx].user->flags & USER_MASTER))
     dprintf(idx, NOTES_FORWARD_TO, e->u.string);
@@ -51,7 +64,7 @@ static void fwd_display(int idx, struct user_entry *e, struct userrec *u)
 
 /* Determine how many notes are waiting for a user.
  */
-static int num_notes(char *user)
+int num_notes(char *user)
 {
   int tot = 0;
   FILE *f;
@@ -182,7 +195,7 @@ static void expire_notes()
 
 /* Add note to notefile.
  */
-static int storenote(char *argv1, char *argv2, char *argv3, int idx, char *who, int bufsize)
+int storenote(char *argv1, char *argv2, char *argv3, int idx, char *who, int bufsize)
 {
   FILE *f;
   char u[20], *f1, *to = NULL, work[1024];
@@ -350,7 +363,7 @@ static int notes_in(int dl[], int in)
  * else    : read msg in list : (ex: .notes read 5-9;12;13;18-)
  * idx=-1  : /msg
  */
-static void notes_read(char *hand, char *nick, char *srd, int idx)
+void notes_read(char *hand, char *nick, char *srd, int idx)
 {
   FILE *f;
   char s[601], *to, *dt, *from, *s1, wt[100];
@@ -462,7 +475,7 @@ static void notes_read(char *hand, char *nick, char *srd, int idx)
  * else    : erase msg in list : (ex: .notes erase 2-4;8;16-)
  * idx=-1  : /msg
  */
-static void notes_del(char *hand, char *nick, char *sdl, int idx)
+void notes_del(char *hand, char *nick, char *sdl, int idx)
 {
   FILE *f, *g;
   char s[513], *to, *s1;
@@ -748,7 +761,7 @@ static cmd_t notes_load[] =
   {NULL,	NULL,	NULL,				NULL}
 };
 
-static void notes_report(int idx, int details)
+void notes_report(int idx, int details)
 {
   if (details) {
     if (notefile[0])
@@ -758,27 +771,11 @@ static void notes_report(int idx, int details)
   }
 }
 
-EXPORT_SCOPE char *notes_start();
-
-static Function notes_table[] =
+void notes_init()
 {
-  (Function) notes_start,
-  (Function) NULL,
-  (Function) 0,
-  (Function) notes_report,
-  (Function) cmd_note,
-  (Function) num_notes,
-};
-
-char *notes_start(Function * global_funcs)
-{
-
-  global = global_funcs;
 
   notefile[0] = 0;
-  module_register(MODULE_NAME, notes_table, 2, 1);
   add_hook(HOOK_HOURLY, (Function) notes_hourly);
-  add_hook(HOOK_STORENOTE, (Function) storenote);
 
   add_builtins("dcc", notes_cmds);
   add_builtins("load", notes_load);
@@ -787,7 +784,6 @@ char *notes_start(Function * global_funcs)
   add_builtins("nkch", notes_nkch);
 
   notes_server_setup(0);
-  my_memcpy(&USERENTRY_FWD, &USERENTRY_INFO, sizeof(void *) * 12);
+  egg_memcpy(&USERENTRY_FWD, &USERENTRY_INFO, sizeof(void *) * 12);
   add_entry_type(&USERENTRY_FWD);
-  return NULL;
 }

+ 9 - 8
src/mod/notes.mod/notes.h

@@ -6,6 +6,9 @@
 #ifndef _EGG_MOD_NOTES_NOTES_H
 #define _EGG_MOD_NOTES_NOTES_H
 
+#include "src/common.h"
+#include "src/users.h"
+
 #define NOTES_IGNKEY "NOTESIGNORE"
 
 /* language #define's */
@@ -56,13 +59,11 @@
 #define NOTES_FWD_CHANGED		"Changed notes forwarding for %s to: %s\n"
 #define NOTES_MUSTBE			"Function must be one of INDEX, READ, or ERASE."
 
-#ifdef MAKING_NOTES
-static void notes_read(char *, char *, char *, int);
-static void notes_del(char *, char *, char *, int);
-static void fwd_display(int, struct user_entry *, struct userrec *);
-#else
-#define num_notes ((int(*)(char *user))notes_funcs[5])
-
-#endif				/* MAKING_NOTES */
+void notes_read(char *, char *, char *, int);
+void notes_del(char *, char *, char *, int);
+void fwd_display(int, struct user_entry *, struct userrec *);
+int num_notes(char *);
+void notes_report(int, int);
+int storenote(char *, char *, char *, int, char *, int);
 
 #endif				/* _EGG_MOD_NOTES_H */

+ 1 - 6
src/mod/static.h

@@ -10,9 +10,6 @@ char *compress_start();
 char *dns_start();
 #ifdef LEAF
 char *irc_start();
-#endif
-char *notes_start();
-#ifdef LEAF
 char *server_start();
 #endif
 char *share_start();
@@ -21,6 +18,7 @@ char *transfer_start();
 void console_init();
 void ctcp_init();
 void update_init();
+void notes_init();
 
 static void link_statics()
 {
@@ -29,9 +27,6 @@ static void link_statics()
   check_static("dns", dns_start);
 #ifdef LEAF
   check_static("irc", irc_start);
-#endif
-  check_static("notes", notes_start);
-#ifdef LEAF
   check_static("server", server_start);
 #endif
   check_static("share", share_start);

+ 0 - 8
src/modules.c

@@ -146,7 +146,6 @@ void (*sharein) (int, char *) = null_share;
 void (*shareupdatein) (int, char *) = null_share;
 void (*qserver) (int, char *, int) = (void (*)(int, char *, int)) null_func;
 void (*add_mode) () = null_func;
-int (*storenote)(char *from, char *to, char *msg, int idx, char *who, int bufsize) = (int (*)(char *from, char *to, char *msg, int idx, char *who, int bufsize)) minus_func;
 int (*rfc_casecmp) (const char *, const char *) = _rfc_casecmp;
 int (*rfc_ncasecmp) (const char *, const char *, int) = _rfc_ncasecmp;
 int (*rfc_toupper) (int) = _rfc_toupper;
@@ -824,10 +823,6 @@ void add_hook(int hook_num, Function func)
 	rfc_toupper = _rfc_toupper;
       }
       break;
-    case HOOK_STORENOTE:
-	if (func == NULL) storenote = (int (*)(char *from, char *to, char *msg, int idx, char *who, int bufsize)) minus_func;
-	else storenote = func;
-	break;
     case HOOK_DNS_HOSTBYIP:
       if (dns_hostbyip == block_dns_hostbyip)
 	dns_hostbyip = (void (*)(IP)) func;
@@ -878,9 +873,6 @@ void del_hook(int hook_num, Function func)
       if (add_mode == (void (*)()) func)
 	add_mode = null_func;
       break;
-    case HOOK_STORENOTE:
-	if (storenote == func) storenote = (int (*)(char *from, char *to, char *msg, int idx, char *who, int bufsize)) minus_func;
-	break;
     case HOOK_DNS_HOSTBYIP:
       if (dns_hostbyip == (void (*)(IP)) func)
 	dns_hostbyip = block_dns_hostbyip;