[mw-devel] MW3 r1150 - trunk/src

welshbyte at sucs.org welshbyte at sucs.org
Mon Jul 12 22:29:38 BST 2010


Author: welshbyte
Date: 2010-07-12 22:29:37 +0100 (Mon, 12 Jul 2010)
New Revision: 1150

Added:
   trunk/src/add.h
   trunk/src/colour.h
   trunk/src/echo.h
   trunk/src/edit.h
   trunk/src/filter.h
   trunk/src/folders.h
   trunk/src/getpass.h
   trunk/src/init.h
   trunk/src/locking.h
   trunk/src/main.h
   trunk/src/mesg.h
   trunk/src/mod.h
   trunk/src/new.h
   trunk/src/perms.h
   trunk/src/read.h
   trunk/src/tidyup.h
   trunk/src/topten.h
   trunk/src/who.h
Removed:
   trunk/src/proto.h
Modified:
   trunk/src/Parse.c
   trunk/src/Parse.h
   trunk/src/add.c
   trunk/src/alarm.h
   trunk/src/alias.c
   trunk/src/alias.h
   trunk/src/bb.h
   trunk/src/bork.h
   trunk/src/chattable.h
   trunk/src/colour.c
   trunk/src/command.h
   trunk/src/completion.c
   trunk/src/edit.c
   trunk/src/expand.h
   trunk/src/files.c
   trunk/src/filter.c
   trunk/src/folders.c
   trunk/src/frl.h
   trunk/src/gags.c
   trunk/src/gags.h
   trunk/src/gagtable.c
   trunk/src/gagtable.h
   trunk/src/getpass.c
   trunk/src/hash.h
   trunk/src/iconv.h
   trunk/src/incoming.c
   trunk/src/incoming.h
   trunk/src/init.c
   trunk/src/ipc.c
   trunk/src/ipc.h
   trunk/src/js.c
   trunk/src/js.h
   trunk/src/log.c
   trunk/src/log.h
   trunk/src/main.c
   trunk/src/mesg.c
   trunk/src/mod.c
   trunk/src/new.c
   trunk/src/newmain.c
   trunk/src/perms.c
   trunk/src/read.c
   trunk/src/rooms.c
   trunk/src/rooms.h
   trunk/src/scrcomplete.h
   trunk/src/script.c
   trunk/src/script.h
   trunk/src/script_inst.c
   trunk/src/script_inst.h
   trunk/src/sort.h
   trunk/src/special.h
   trunk/src/sqlite.h
   trunk/src/strings.c
   trunk/src/strings.h
   trunk/src/talker.c
   trunk/src/talker.h
   trunk/src/talker_privs.c
   trunk/src/talker_privs.h
   trunk/src/tidyup.c
   trunk/src/topten.c
   trunk/src/uri.c
   trunk/src/uri.h
   trunk/src/user.c
   trunk/src/user.h
   trunk/src/who.c
Log:
Some header file refactoring:
- Get rid of proto.h and split out its declarations into new .h files matching the .c files in which the definitions will be found
- Use include guards in headers
- Reorganise a couple of functions to make them static

NB this is just the first step. Some of the additional headers can probably be obsoleted with further refactoring as they only contain one or two declarations - there's plenty of scope for better organisation of .c files (e.g. get_pass and other utility functions could be combined into a util.c).



Modified: trunk/src/Parse.c
===================================================================
--- trunk/src/Parse.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/Parse.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -4,7 +4,9 @@
 #include <ctype.h>
 #include <unistd.h>
 #include "bb.h"
-#include "proto.h"
+#include "init.h"
+#include "talker.h"
+#include "strings.h"
 
 #include "Parse.h"
 #include "talker_privs.h"

Modified: trunk/src/Parse.h
===================================================================
--- trunk/src/Parse.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/Parse.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -90,4 +90,7 @@
 extern void c_alias(CommandList *cm, int argc, char **argv, char *args);
 extern void c_unalias(CommandList *cm, int argc, char **argv, char *args);
 
+void help_list(CommandList *c, unsigned int hidestuff);
+char *remove_first_word(char *args);
+
 #endif

Modified: trunk/src/add.c
===================================================================
--- trunk/src/add.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/add.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -15,6 +15,14 @@
 #include "bb.h"
 #include "alarm.h"
 #include "strings.h"
+#include "perms.h"
+#include "read.h"
+#include "user.h"
+#include "main.h"
+#include "filter.h"
+#include "init.h"
+#include "locking.h"
+#include "mesg.h"
 extern int eof_caught;
 extern int remote;
 extern int busy;

Added: trunk/src/add.h
===================================================================
--- trunk/src/add.h	                        (rev 0)
+++ trunk/src/add.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,8 @@
+#ifndef ADD_H
+#define ADD_H
+
+#include "bb.h"
+
+int add_msg(int folnum,struct person *user,int replyto);
+
+#endif /* ADD_H */

Modified: trunk/src/alarm.h
===================================================================
--- trunk/src/alarm.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/alarm.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,5 @@
+#ifndef ALARM_H
+#define ALARM_H
 
 #include <sys/time.h>
 #include <sys/types.h>
@@ -26,3 +28,5 @@
 struct alarm *alarm_after(long secs, long usecs, void *what, void (*how)(void *));
 void alarm_sleep(struct timeval *delay, int resume); 
 int alarm_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+
+#endif /* ALARM_H */

Modified: trunk/src/alias.c
===================================================================
--- trunk/src/alias.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/alias.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -6,6 +6,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include "bb.h"
+#include "talker.h"
+#include "strings.h"
+#include "main.h"
 
 #include "alias.h"
 Alias alias_list=NULL;

Modified: trunk/src/alias.h
===================================================================
--- trunk/src/alias.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/alias.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,5 @@
+#ifndef ALIAS_H
+#define ALIAS_H
 
 typedef struct alias_record 
 {
@@ -6,7 +8,6 @@
 	struct alias_record *next;
 } *Alias;
 
-/* Prototypes */
 void DestroyAllLinks(Alias *list);
 int DestroyLink(Alias *list, char *name);
 int AddLink(Alias *list, char *from, char *to);
@@ -15,3 +16,5 @@
 char *list_bind(const char *text, int state);
 char *list_bind_rl(const char *text, int state);
 char *NextLink(Alias list, char *prev);
+
+#endif /* ALIAS_H */

Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/bb.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef BB_H
+#define BB_H
+
 /* bb.h
  * Miscellaneous structures/constants.
  */
@@ -2,6 +5,2 @@
 
-#ifndef BB_H
-#define BB_H
-
-/* portable integer types */
 #include <stdint.h>
@@ -232,7 +231,6 @@
 #define PACKAGE	"mw"
 #define LOCALEDIR HOMEPATH"/locale"
 
-#include "proto.h"
 extern mode_t	umask __P ((mode_t __mask)); /* from unistd.h.old */
 
 

Modified: trunk/src/bork.h
===================================================================
--- trunk/src/bork.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/bork.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,12 +1,8 @@
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#ifndef BORK_H
+#define BORK_H
 
-struct pattern {
-    char *from;
-    char *to;
-};
-
 #include "gagtable.h"
 
 char *apply_bork(char *text, const struct pattern *list, int caps);
+
+#endif /* BORK_H */

Modified: trunk/src/chattable.h
===================================================================
--- trunk/src/chattable.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/chattable.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef CHATTABLE_H
+#define CHATTABLE_H
+
 #include "talker.h"
 #include "Parse.h"
 
@@ -4,4 +7,4 @@
 /* command string table, whilst in talker mode */
 extern CommandList chattable[];
 
-/* Now defined in chattable.c */
+#endif /* CHATTABLE_H */

Modified: trunk/src/colour.c
===================================================================
--- trunk/src/colour.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/colour.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -10,7 +10,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include "bb.h"
-#include "proto.h"
 #include "frl.h"
 #define COLOUR_LIMIT 40
 

Added: trunk/src/colour.h
===================================================================
--- trunk/src/colour.h	                        (rev 0)
+++ trunk/src/colour.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,11 @@
+#ifndef COLOUR_H
+#define COLOUR_H
+
+void init_colour(void);
+void destroy_colours(void);
+void colour_load(char *file, int quiet);
+void colour_free(void);
+char *colour(char *text, int *concealed);
+char *get_colour(void);
+
+#endif /* COLOUR_H */

Modified: trunk/src/command.h
===================================================================
--- trunk/src/command.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/command.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef COMMAND_H
+#define COMMAND_H
+
 #include "Parse.h"
 
 extern CommandList table[];
@@ -2,2 +5,2 @@
 
-/* Now defined in command.c */
+#endif /* COMMAND_H */

Modified: trunk/src/completion.c
===================================================================
--- trunk/src/completion.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/completion.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,8 +1,10 @@
 #include "completion.h"
 #include "bb.h"
-#include "proto.h"
 #include "script.h"
 #include "uri.h"
+#include "main.h"
+#include "talker_privs.h"
+#include "alias.h"
 
 /*
   modes:	0 - commands

Added: trunk/src/echo.h
===================================================================
--- trunk/src/echo.h	                        (rev 0)
+++ trunk/src/echo.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,10 @@
+#ifndef ECHO_H
+#define ECHO_H
+
+void echo_off(void);
+void echo_on(void);
+void force_line_mode(void);
+void save_terminal(void);
+void fix_terminal(void);
+
+#endif /* ECHO_H */

Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/edit.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -20,6 +20,15 @@
 #include "ipc.h"
 #include "files.h"
 #include "strings.h"
+#include "perms.h"
+#include "mesg.h"
+#include "user.h"
+#include "getpass.h"
+#include "who.h"
+#include "edit.h"
+#include "locking.h"
+#include "init.h"
+#include "read.h"
 
 char *partlist_user[]={
 "edit", "status", "special", "groups", "passwd", "chatprivs", "chatmode",
@@ -31,6 +40,102 @@
 extern struct person *user;
 extern long userposn;
 
+static void edit_all(struct person *usr)
+{
+	int i,r;
+	char tmp[80];	
+	
+	printf("Editing user %s\n",usr->name);
+	printf("Enter new data for each field <cr> to leave unchanged.\n");
+	
+	printf("realname: %s\nnew name: ",usr->realname);
+	get_str(tmp,REALNAMESIZE);
+	if (strlen(tmp)!=0) strcpy(usr->realname,tmp);
+	printf("email: %s\nnew email: ",usr->contact);
+	get_str(tmp,CONTACTSIZE);
+	if (strlen(tmp)!=0) strcpy(usr->contact,tmp);
+	printf("subscribed %lo %lo\nsubscibed: ",(unsigned long)usr->folders[0],(unsigned long)usr->folders[1]);
+	get_str(tmp,10);
+	if (strlen(tmp)!=0) usr->folders[0]=atoi(tmp);
+	printf("last message read (folder:message) -\n");
+	for (i=0;i<11;i++) printf("%2d:%03d ",i,usr->lastread[i]);
+	printf("\n");
+	for (i=11;i<22;i++) printf("%2d:%03d ",i,usr->lastread[i]);
+	printf("\n");
+	for (i=22;i<32;i++) printf("%2d:%03d ",i,usr->lastread[i]);
+	printf("\n");
+	for (;;)
+	{
+		printf("set read - <folder> <message>:");
+		get_str(tmp,20);
+		if (strlen(tmp)==0) break;
+		sscanf(tmp,"%d %d",&i,&r);
+		usr->lastread[i]=r;
+		sprintf(tmp, "%d:%d", i, r);
+		ipc_send_to_username(usr->name, IPC_LASTREAD, tmp);
+	}
+	show_user_stats(usr->status,tmp,TRUE);
+	printf("current status %s\nnew status: ",tmp);
+	get_str(tmp,20);
+	if (*tmp) 
+	{
+		usr->status=user_stats(tmp,usr->status);
+		show_user_stats(usr->status,tmp,FALSE);
+		printf("status now set to [%s]\n",tmp);
+	}
+}
+
+static void show_change(char *old, char *new, char *fmt, ...)
+{
+	va_list va;
+	char text[MAXTEXTLENGTH];
+	char add[MAXTEXTLENGTH];
+	char sub[MAXTEXTLENGTH];
+	char buff[2];
+	int i;
+
+	va_start(va, fmt);
+        vsnprintf(text, MAXTEXTLENGTH-1, fmt, va);
+	va_end(va);
+
+	/* calulate sub */
+	sub[0] = 0;
+	for (i=0; i < strlen(old); i++)
+	{
+		if ((strchr(new, old[i]) == NULL) && (new[i]!='-') && (old[i]!='-'))
+		{
+			buff[0] = old[i];
+			buff[1] = 0;
+			strncat(sub, buff, MAXTEXTLENGTH - strlen(sub) - 1);
+		}
+	}
+	
+	/* calulate add */
+	add[0] = 0;
+	for (i=0; i < strlen(new); i++)
+	{
+		if ((strchr(old, new[i]) == NULL) && (new[i]!='-'))
+		{
+			buff[0] = new[i];
+			buff[1] = 0;
+			strncat(add, buff, MAXTEXTLENGTH - strlen(sub) - 1);
+		}
+	}
+
+	if (add[0]!=0)
+	{
+		strncat(text, " +", MAXTEXTLENGTH - strlen(text) - 1);
+		strncat(text, add, MAXTEXTLENGTH - strlen(text) - 1);
+	}
+	if (sub[0]!=0)
+	{
+		strncat(text, " -", MAXTEXTLENGTH - strlen(text) - 1);
+		strncat(text, sub, MAXTEXTLENGTH - strlen(text) - 1);
+	}
+	if (add[0]==0 && sub[0]==0) return;
+	broadcast(3, text);
+}
+
 void edit_user(char *args, char *name)
 {
 	int32_t usrposn;
@@ -488,54 +593,27 @@
 }
 
 
-void edit_all(struct person *usr)
+char *partlist_folder[]={"status", "groups", "name", "size", "view", "topic",
+"delete", NULL};
+
+static void users_lastread(int folnum)
 {
-	int i,r;
-	char tmp[80];	
+	struct person user;
+	int ufile;
 	
-	printf("Editing user %s\n",usr->name);
-	printf("Enter new data for each field <cr> to leave unchanged.\n");
-	
-	printf("realname: %s\nnew name: ",usr->realname);
-	get_str(tmp,REALNAMESIZE);
-	if (strlen(tmp)!=0) strcpy(usr->realname,tmp);
-	printf("email: %s\nnew email: ",usr->contact);
-	get_str(tmp,CONTACTSIZE);
-	if (strlen(tmp)!=0) strcpy(usr->contact,tmp);
-	printf("subscribed %lo %lo\nsubscibed: ",(unsigned long)usr->folders[0],(unsigned long)usr->folders[1]);
-	get_str(tmp,10);
-	if (strlen(tmp)!=0) usr->folders[0]=atoi(tmp);
-	printf("last message read (folder:message) -\n");
-	for (i=0;i<11;i++) printf("%2d:%03d ",i,usr->lastread[i]);
-	printf("\n");
-	for (i=11;i<22;i++) printf("%2d:%03d ",i,usr->lastread[i]);
-	printf("\n");
-	for (i=22;i<32;i++) printf("%2d:%03d ",i,usr->lastread[i]);
-	printf("\n");
-	for (;;)
+	ufile=openuserfile(O_RDWR);
+	Lock_File(ufile);
+	while (read(ufile,&user,sizeof(user))>0)
 	{
-		printf("set read - <folder> <message>:");
-		get_str(tmp,20);
-		if (strlen(tmp)==0) break;
-		sscanf(tmp,"%d %d",&i,&r);
-		usr->lastread[i]=r;
-		sprintf(tmp, "%d:%d", i, r);
-		ipc_send_to_username(usr->name, IPC_LASTREAD, tmp);
+		lseek(ufile,-1*sizeof(user),1);
+		user.lastread[folnum]=0;
+		user.folders[0]|=(1<<folnum);
+		write(ufile,&user,sizeof(user));
 	}
-	show_user_stats(usr->status,tmp,TRUE);
-	printf("current status %s\nnew status: ",tmp);
-	get_str(tmp,20);
-	if (*tmp) 
-	{
-		usr->status=user_stats(tmp,usr->status);
-		show_user_stats(usr->status,tmp,FALSE);
-		printf("status now set to [%s]\n",tmp);
-	}
+	Unlock_File(ufile);
+	close(ufile);
 }
 
-char *partlist_folder[]={"status", "groups", "name", "size", "view", "topic",
-"delete", NULL};
-
 void edit_folder(char *args, char *name)
 {
 	char fullpath[256];
@@ -709,24 +787,6 @@
 	close(afile);	
 }	
 
-void users_lastread(int folnum)
-{
-	struct person user;
-	int ufile;
-	
-	ufile=openuserfile(O_RDWR);
-	Lock_File(ufile);
-	while (read(ufile,&user,sizeof(user))>0)
-	{
-		lseek(ufile,-1*sizeof(user),1);
-		user.lastread[folnum]=0;
-		user.folders[0]|=(1<<folnum);
-		write(ufile,&user,sizeof(user));
-	}
-	Unlock_File(ufile);
-	close(ufile);
-}
-	
 char *partlist_mesg[]={
 "edit", "to", "subject", "delete", "undelete", "status", NULL};
 
@@ -918,58 +978,6 @@
 	printf(_("%d second%s.\n"),s,s==1?"":"s");
 }
 
-void show_change(char *old, char *new, char *fmt, ...)
-{
-	va_list va;
-	char text[MAXTEXTLENGTH];
-	char add[MAXTEXTLENGTH];
-	char sub[MAXTEXTLENGTH];
-	char buff[2];
-	int i;
-
-	va_start(va, fmt);
-        vsnprintf(text, MAXTEXTLENGTH-1, fmt, va);
-	va_end(va);
-
-	/* calulate sub */
-	sub[0] = 0;
-	for (i=0; i < strlen(old); i++)
-	{
-		if ((strchr(new, old[i]) == NULL) && (new[i]!='-') && (old[i]!='-'))
-		{
-			buff[0] = old[i];
-			buff[1] = 0;
-			strncat(sub, buff, MAXTEXTLENGTH - strlen(sub) - 1);
-		}
-	}
-	
-	/* calulate add */
-	add[0] = 0;
-	for (i=0; i < strlen(new); i++)
-	{
-		if ((strchr(old, new[i]) == NULL) && (new[i]!='-'))
-		{
-			buff[0] = new[i];
-			buff[1] = 0;
-			strncat(add, buff, MAXTEXTLENGTH - strlen(sub) - 1);
-		}
-	}
-
-	if (add[0]!=0)
-	{
-		strncat(text, " +", MAXTEXTLENGTH - strlen(text) - 1);
-		strncat(text, add, MAXTEXTLENGTH - strlen(text) - 1);
-	}
-	if (sub[0]!=0)
-	{
-		strncat(text, " -", MAXTEXTLENGTH - strlen(text) - 1);
-		strncat(text, sub, MAXTEXTLENGTH - strlen(text) - 1);
-	}
-	if (add[0]==0 && sub[0]==0) return;
-	broadcast(3, text);
-}
-
-
 void edit_contact(void)
 {
 	char	contact[CONTACTSIZE+1];

Added: trunk/src/edit.h
===================================================================
--- trunk/src/edit.h	                        (rev 0)
+++ trunk/src/edit.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,12 @@
+#ifndef EDIT_H
+#define EDIT_H
+
+#include "bb.h"
+
+void time_on(long u);
+void edit_user(char *args, char *name);
+void edit_folder(char *args, char *name);
+void edit_contact(void);
+void mesg_edit(char *args, char *foldername, int msgno, struct person *usr);
+
+#endif /* EDIT_H */

Modified: trunk/src/expand.h
===================================================================
--- trunk/src/expand.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/expand.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef EXPAND_H
+#define EXPAND_H
+
 #include "script.h"
 
 struct expand_buf
@@ -13,3 +16,5 @@
 /*int call_with_var_op(char *varname, var_func_t *func, void *arg);*/
 int eval_var(char *name, var_op_t *op);
 void expand_close(void);
+
+#endif /* EXPAND_H */

Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/files.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -13,6 +13,9 @@
 #include <string.h>
 #include <errno.h>
 #include "strings.h"
+#include "user.h"
+#include "perms.h"
+#include "locking.h"
 
 static int createuserfile()
 {

Modified: trunk/src/filter.c
===================================================================
--- trunk/src/filter.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/filter.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -6,6 +6,7 @@
 
 #include <stdio.h>
 #include "bb.h"
+#include "talker.h"
 
 void tidy_string(char *buff)
 {

Added: trunk/src/filter.h
===================================================================
--- trunk/src/filter.h	                        (rev 0)
+++ trunk/src/filter.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,7 @@
+#ifndef FILTER_H
+#define FILTER_H
+
+void tidy_string(char *buff);
+void filter_returns(char *buff);
+
+#endif /* FILTER_H */

Modified: trunk/src/folders.c
===================================================================
--- trunk/src/folders.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/folders.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -11,6 +11,12 @@
 #include <string.h>
 #include "bb.h"
 #include "ipc.h"
+#include "files.h"
+#include "strings.h"
+#include "perms.h"
+#include "folders.h"
+#include "locking.h"
+#include "user.h"
 
 void add_folder(void)
 {

Added: trunk/src/folders.h
===================================================================
--- trunk/src/folders.h	                        (rev 0)
+++ trunk/src/folders.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,7 @@
+#ifndef FOLDERS_H
+#define FOLDERS_H
+
+void auto_subscribe(int folnum, int state);
+void add_folder(void);
+
+#endif /* FOLDERS_H */

Modified: trunk/src/frl.h
===================================================================
--- trunk/src/frl.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/frl.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef FRL_H
+#define FRL_H
+
 /**************************************************************
 **        Name: File Readline Utilities (frl)                **
 **      Author: Chris Fry                                    **
@@ -5,6 +8,8 @@
 ** Description: Utilies to read lines from a file            **
 **************************************************************/
 
+#include <stdio.h>
+
 typedef struct __str_list {
 	char *text;
 	struct __str_list *next;
@@ -35,3 +40,4 @@
 
 long num_lines_read(void);
 
+#endif /* FRL_H */

Modified: trunk/src/gags.c
===================================================================
--- trunk/src/gags.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/gags.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
 #include "bork.h"
 #include "gags.h"
 #include "bb.h"
@@ -214,6 +217,17 @@
 	free(old);
 }
 
+static char *duplstr(char *text)
+{
+	char *c;
+	int i;
+	c=(char *)malloc(strlen(text)+1);
+	for (i=0;i<strlen(text);i++)
+		c[i]=tolower(text[i]);
+	c[strlen(text)]=0;
+	return(c);
+}
+
 /* tnarg dyslexication filter */
 void gag_tnarg(char *text)
 {

Modified: trunk/src/gags.h
===================================================================
--- trunk/src/gags.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/gags.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef GAGS_H
+#define GAGS_H
+
 /* function prototypes */
 void gag_normal(char *text);
 void gag_chef(char *text);
@@ -25,3 +28,5 @@
 
 /* maximum gag flag used */
 #define MAX_GAG_FLAG	6
+
+#endif /* GAGS_H */

Modified: trunk/src/gagtable.c
===================================================================
--- trunk/src/gagtable.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/gagtable.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,4 @@
+#include <stddef.h>
 #include "bork.h"
 /*
    in the FROM pattern:

Modified: trunk/src/gagtable.h
===================================================================
--- trunk/src/gagtable.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/gagtable.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,11 @@
+#ifndef GAGTABLE_H
+#define GAGTABLE_H
+
+struct pattern {
+    char *from;
+    char *to;
+};
+
 extern const struct pattern chef[];
 extern const struct pattern kraut[];
 extern const struct pattern fudd[];
@@ -11,3 +19,5 @@
 extern const struct pattern french[];
 extern const struct pattern babelfish[];
 extern const struct pattern nosport[];
+
+#endif /* GAGTABLE_H */

Modified: trunk/src/getpass.c
===================================================================
--- trunk/src/getpass.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/getpass.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -6,6 +6,7 @@
 
 #include <stdio.h>
 #include "bb.h"
+#include "echo.h"
 
 char *get_pass(char *p)
 {

Added: trunk/src/getpass.h
===================================================================
--- trunk/src/getpass.h	                        (rev 0)
+++ trunk/src/getpass.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,6 @@
+#ifndef GETPASS_H
+#define GETPASS_H
+
+char *get_pass(char *p);
+
+#endif /* GETPASS_H */

Modified: trunk/src/hash.h
===================================================================
--- trunk/src/hash.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/hash.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,4 +1,5 @@
-/* hash.h */
+#ifndef HASH_H
+#define HASH_H
 
 #define FS_UNMARKED 0
 #define FS_MARKED 1
@@ -63,3 +64,5 @@
 void hash_delete(hash_op_t *op);
 void hash_purge(int field);
 void hashcode(int field, const char *key);
+
+#endif /* HASH_H */

Modified: trunk/src/iconv.h
===================================================================
--- trunk/src/iconv.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/iconv.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef ICONV_H
+#define ICONV_H
+
 #include <wchar.h>
 
 int convert_string_charset(char *input_buffer, char *input_charset, size_t input_length,
@@ -38,3 +41,5 @@
 #define WOUTPUTTOOSHORT 1
 #define WINVALIDCHARS 2
 #define WICONVFAIL 4
+
+#endif /* ICONV_H */

Modified: trunk/src/incoming.c
===================================================================
--- trunk/src/incoming.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/incoming.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -12,7 +12,7 @@
 
 #include "bb.h"
 #include "incoming.h"
-#include "proto.h"
+#include "main.h"
 #include "talker_privs.h"
 #include "special.h"
 #include "chattable.h"
@@ -21,6 +21,11 @@
 #include "alias.h"
 #include "script.h"
 #include "ipc.h"
+#include "perms.h"
+#include "who.h"
+#include "user.h"
+#include "mesg.h"
+#include "echo.h"
 
 extern int script_terminate;
 extern Alias rpc_list;

Modified: trunk/src/incoming.h
===================================================================
--- trunk/src/incoming.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/incoming.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef INCOMING_H
+#define INCOMING_H
+
 /* Incoming message flags */
 #define MST_EVENT	0x01	/* Event script will be called */
 #define MST_BEEP	0x02	/* Message will be accompanied by a beep */
@@ -37,3 +40,5 @@
 void DisplayStack(void);
 void ClearStack(void);
 void PopMesg(void);
+
+#endif /* INCOMING_H */

Modified: trunk/src/init.c
===================================================================
--- trunk/src/init.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/init.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -36,6 +36,24 @@
 void LoadFunction(char *, char *, FILE *, int *, const char *, int);
 void DestroyFunction(char *);
 
+/* drop and restore user level privs */
+static int private_myid = -1;
+
+int perms_drop(void)
+{
+	private_myid=geteuid();
+	if (seteuid(getuid()) == -1) return -1;
+	return private_myid;
+}
+
+void perms_restore(void)
+{
+	if (private_myid != -1) {
+		seteuid(private_myid);
+		private_myid = -1;
+	}
+}
+
 void LoadInitFile(char *name)
 {
 	struct passwd *pw;
@@ -420,20 +438,4 @@
 	return 0;
 }
 
-/* drop and restore user level privs */
-static int private_myid = -1;
 
-int perms_drop(void)
-{
-	private_myid=geteuid();
-	if (seteuid(getuid()) == -1) return -1;
-	return private_myid;
-}
-
-void perms_restore(void)
-{
-	if (private_myid != -1) {
-		seteuid(private_myid);
-		private_myid = -1;
-	}
-}

Added: trunk/src/init.h
===================================================================
--- trunk/src/init.h	                        (rev 0)
+++ trunk/src/init.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,8 @@
+#ifndef INIT_H
+#define INIT_H
+
+int perms_drop(void);
+void perms_restore(void);
+void LoadInitFile(char *name);
+
+#endif /* INIT_H */

Modified: trunk/src/ipc.c
===================================================================
--- trunk/src/ipc.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/ipc.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,14 +1,17 @@
 
+#include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "proto.h"
 #include "ipc.h"
 #include "iconv.h"
 #include "talker.h"
+#include "mesg.h"
+#include "who.h"
+#include "files.h"
 
 /*
  * Send a message to a remote process addressed by PID

Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/ipc.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,6 +1,8 @@
-#ifndef __IPC_H__
-#define __IPC_H__
+#ifndef IPC_H
+#define IPC_H
 
+#include "bb.h"
+
 enum ipc_types {
 	IPC_NOOP	= 0,	// Just go through the motions, don't actually write anything to the FIFO
 	IPC_NEWMAIL	= 1,

Modified: trunk/src/js.c
===================================================================
--- trunk/src/js.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/js.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -17,7 +17,6 @@
 #include <jsdbgapi.h>
 
 #include "bb.h"
-#include "proto.h"
 #include "sqlite.h"
 #include "chattable.h"
 #include "script.h"
@@ -26,6 +25,10 @@
 #include "alias.h"
 #include "alarm.h"
 #include "log.h"
+#include "main.h"
+#include "files.h"
+#include "user.h"
+#include "init.h"
 
 extern Alias alias_list;
 extern Alias bind_list;

Modified: trunk/src/js.h
===================================================================
--- trunk/src/js.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/js.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,4 +1,8 @@
-/* js.c */
+#ifndef JS_H
+#define JS_H
+
+#include <stdio.h>
+
 int js_isrunning();
 int js_exec(char *name, int argc, char **argvc);
 int load_jsfile(FILE *f, char *filename);
@@ -8,3 +12,5 @@
 int stop_js(void);
 int setup_js(void);
 size_t urldata(void *ptr, size_t size, size_t nmemb, void *stream);
+
+#endif /* JS_H */

Added: trunk/src/locking.h
===================================================================
--- trunk/src/locking.h	                        (rev 0)
+++ trunk/src/locking.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,7 @@
+#ifndef LOCKING_H
+#define LOCKING_H
+
+void Lock_File(int f);
+void Unlock_File(int f);
+
+#endif /* LOCKING_H */

Modified: trunk/src/log.c
===================================================================
--- trunk/src/log.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/log.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -17,7 +17,6 @@
 #include "Parse.h"
 #include "talker_privs.h"
 #include "special.h"
-#include "proto.h"
 #include "talker.h"
 #include "gags.h"
 #include "strings.h"

Modified: trunk/src/log.h
===================================================================
--- trunk/src/log.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/log.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,4 +1,6 @@
-/* log.c */
+#ifndef LOG_H
+#define LOG_H
+
 void catchuri(const char *what);
 void catchdoing(const char *what);
 
@@ -14,3 +16,5 @@
 void block_free(struct block_t *);
 void block_resize(struct block_t *, int);
 int block_append(struct block_t *p, void *data, int size);
+
+#endif /* LOG_H */

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/main.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -36,15 +36,24 @@
 
 #include "talker_privs.h"
 #include "special.h"
-#include "proto.h"
 #include "frl.h"
 #include "files.h"
 
 #include "incoming.h"
 #include "script.h"
 #include "rooms.h"
+#include "perms.h"
 #include "ipc.h"
 #include "js.h"
+#include "mesg.h"
+#include "main.h"
+#include "user.h"
+#include "new.h"
+#include "who.h"
+#include "echo.h"
+#include "add.h"
+#include "colour.h"
+#include "init.h"
 
 #include <pwd.h>
 #include <grp.h>
@@ -108,19 +117,8 @@
 
 /* readline stuff */
 int UseRL=0;
-char *list_commands(const char *text, int state);
-char *list_chat_commands(const char *text, int state);
-char *dummy_list(const char *text, int state);
-char *find_folder(const char *text, int state);
-char *part_who(const char *text, int status);
-char *part_who_talk(const char *text, int status);
-char *part_user(const char *text, int status);
-char *part_comm_user(const char *text, int status);
-char *part_comm_folder(const char *text, int status);
-char *part_comm_mesg(const char *text, int status);
 char **complete_entry(const char *text, int start, int end);
-static void restore_tty(void);
-char *getmylogin(void);
+void accept_command(char *comm);
 static void interrupt(int sig);
 void DoScript(char *line);
 
@@ -153,30 +151,50 @@
 	current_rights = RIGHTS_BBS;
 }
 
-void enable_rl()
+static void set_prompt()
 {
-	if (inreadline) return;
-	set_prompt();
-	inreadline = 1;
-	if (!UseRL)
+	char pre[20];
+
+	if (UseRL) 
+		sprintf(pre,"%s", "");
+		/*sprintf(pre,"%s",clear_line);*/
+	else strcpy(pre,"\r");
+
+	if (is_stacked())
 	{
-		printf("%s", prompt);
-		fflush(stdout);
-		return;
+		prompt[0]=0;
 	}
-	rl_callback_handler_install(prompt, &accept_line);
-	if (saved_rl_text)
+	else
 	{
-		history_set_pos(saved_history);
-		rl_insert_text(saved_rl_text);
-		rl_mark = saved_rl_mark;
-		rl_point = saved_rl_point;
-		rl_redisplay();
-		free(saved_rl_text);
-		saved_rl_text = NULL;
+		if (cm_flags(user->chatmode,CM_ONCHAT,CM_MODE_ANY)) 
+			snprintf(prompt,40, "%stalk{%d}-* ",pre,user->room);
+		else
+		if (u_god(user->status))
+			snprintf(prompt,40,"%s{%s}---* ",pre,fold->name);
+		else
+		if (u_reg(user->status))
+			snprintf(prompt,40, "%s<%s>---> ",pre,fold->name);
+		else
+			snprintf(prompt,40, "%s[%s] _@/ ",pre,fold->name);
 	}
 }
 
+void restore_tty(void)
+{
+	struct termios termios;
+
+	if (UseRL)
+	{
+		/* Readline may not restore these settings if the
+		 * callback interface is used.
+		 */
+		tcgetattr(0, &termios);
+		termios.c_lflag |= ICANON|ECHO;
+		termios.c_iflag |= ICRNL;
+		tcsetattr(0, TCSANOW, &termios);
+	}
+}
+
 int disable_rl(int savetext)
 {
 	if (!inreadline) return 0;
@@ -199,6 +217,83 @@
 	return 1;
 }
 
+void accept_line(char *line)
+{
+	int conversion_result;
+	if (line == NULL)
+	{
+		*comm=0;
+		eof_count++;
+		mwlog("EOF");
+		if (eof_count>3)
+		{
+			broadcast(1, "\03304%s%s connection has just dropped." ,user->name, user->name[strlen(user->name)]=='s'?"'":"'s");
+			mwlog("EOF(LOGOUT)");
+			close_down(2, NULL, NULL);
+		}
+	} else
+	{
+		
+		//strncpy(comm, line, MAXTEXTLENGTH-1);
+		//comm[MAXTEXTLENGTH-1] = '\0';
+		conversion_result=convert_string_charset(line, "LOCAL", strlen(line), comm, "UTF-8", MAXTEXTLENGTH-100, NULL, NULL, NULL, NULL, "?");
+		if(conversion_result >= 0)
+		{
+			if( conversion_result & WINVALIDCHARS )
+			{
+				printf("Warning: Your input contained characters that are invalid in your current locale.\n  Please ensure your terminal and locale are using the same character set\n"); 
+			}
+			eof_count=0;
+			strip_str(comm); 
+			if (new_mail_waiting==1)
+			{
+				display_message(_("\03305*** You have new mail.\n"), 1, 1);
+				new_mail_waiting=0;
+			}else
+			if (new_mail_waiting>1)
+			{
+				char tbuff[MAXTEXTLENGTH];
+				snprintf(tbuff, MAXTEXTLENGTH-1, _("\03305*** You have %d new mail messages.\n"),new_mail_waiting);
+				display_message(tbuff, 1, 1);
+				new_mail_waiting=0;
+			}
+			user->idletime=time(0);
+			update_user(user,userposn);
+			if (*comm == 0) return;
+	#ifdef RWHO
+			rwho_update();
+	#endif 
+			disable_rl(0);
+			update_user(user,userposn);
+			stack_str(comm);
+		}
+	}
+}
+
+void enable_rl()
+{
+	if (inreadline) return;
+	set_prompt();
+	inreadline = 1;
+	if (!UseRL)
+	{
+		printf("%s", prompt);
+		fflush(stdout);
+		return;
+	}
+	rl_callback_handler_install(prompt, &accept_line);
+	if (saved_rl_text)
+	{
+		history_set_pos(saved_history);
+		rl_insert_text(saved_rl_text);
+		rl_mark = saved_rl_mark;
+		rl_point = saved_rl_point;
+		rl_redisplay();
+		free(saved_rl_text);
+		saved_rl_text = NULL;
+	}
+}
+
 int match_arg_str(char *search, char *sub)
 {
 	char *match;
@@ -261,6 +356,10 @@
 	signal(SIGWINCH, termcap_screenchange);
 }
 
+static char *dummy_list(const char *text, int state)
+{
+	return(NULL);
+}
 
 int main(int argc, char **argv)
 {
@@ -727,87 +826,6 @@
 	}	
 }
 
-void set_prompt()
-{
-	char pre[20];
-
-	if (UseRL) 
-		sprintf(pre,"%s", "");
-		/*sprintf(pre,"%s",clear_line);*/
-	else strcpy(pre,"\r");
-
-	if (is_stacked())
-	{
-		prompt[0]=0;
-	}
-	else
-	{
-		if (cm_flags(user->chatmode,CM_ONCHAT,CM_MODE_ANY)) 
-			snprintf(prompt,40, "%stalk{%d}-* ",pre,user->room);
-		else
-		if (u_god(user->status))
-			snprintf(prompt,40,"%s{%s}---* ",pre,fold->name);
-		else
-		if (u_reg(user->status))
-			snprintf(prompt,40, "%s<%s>---> ",pre,fold->name);
-		else
-			snprintf(prompt,40, "%s[%s] _@/ ",pre,fold->name);
-	}
-}
-
-void accept_line(char *line)
-{
-	int conversion_result;
-	if (line == NULL)
-	{
-		*comm=0;
-		eof_count++;
-		mwlog("EOF");
-		if (eof_count>3)
-		{
-			broadcast(1, "\03304%s%s connection has just dropped." ,user->name, user->name[strlen(user->name)]=='s'?"'":"'s");
-			mwlog("EOF(LOGOUT)");
-			close_down(2, NULL, NULL);
-		}
-	} else
-	{
-		
-		//strncpy(comm, line, MAXTEXTLENGTH-1);
-		//comm[MAXTEXTLENGTH-1] = '\0';
-		conversion_result=convert_string_charset(line, "LOCAL", strlen(line), comm, "UTF-8", MAXTEXTLENGTH-100, NULL, NULL, NULL, NULL, "?");
-		if(conversion_result >= 0)
-		{
-			if( conversion_result & WINVALIDCHARS )
-			{
-				printf("Warning: Your input contained characters that are invalid in your current locale.\n  Please ensure your terminal and locale are using the same character set\n"); 
-			}
-			eof_count=0;
-			strip_str(comm); 
-			if (new_mail_waiting==1)
-			{
-				display_message(_("\03305*** You have new mail.\n"), 1, 1);
-				new_mail_waiting=0;
-			}else
-			if (new_mail_waiting>1)
-			{
-				char tbuff[MAXTEXTLENGTH];
-				snprintf(tbuff, MAXTEXTLENGTH-1, _("\03305*** You have %d new mail messages.\n"),new_mail_waiting);
-				display_message(tbuff, 1, 1);
-				new_mail_waiting=0;
-			}
-			user->idletime=time(0);
-			update_user(user,userposn);
-			if (*comm == 0) return;
-	#ifdef RWHO
-			rwho_update();
-	#endif 
-			disable_rl(0);
-			update_user(user,userposn);
-			stack_str(comm);
-		}
-	}
-}
-
 void accept_command(char *comm)
 {
 	char history_comm[MAXTEXTLENGTH];
@@ -961,22 +979,6 @@
 	exit(0);
 }
 
-void restore_tty(void)
-{
-	struct termios termios;
-
-	if (UseRL)
-	{
-		/* Readline may not restore these settings if the
-		 * callback interface is used.
-		 */
-		tcgetattr(0, &termios);
-		termios.c_lflag |= ICANON|ECHO;
-		termios.c_iflag |= ICRNL;
-		tcsetattr(0, TCSANOW, &termios);
-	}
-}
-
 void printfile(char *filename)
 {
 	FILE *afile;
@@ -1016,101 +1018,6 @@
 	fclose(afile);
 }
 
-
-void help(char *topic, int wiz)
-{
-	CommandList	*c;
-	char		*x = NULL;
-	int		found=FALSE;
-
-	if (topic!=NULL && (strchr(topic,'.')!=NULL || strchr(topic,'/')!=NULL))
-	{
-		printf(_("Sorry, no help available on that subject.\n"));
-		return;
-	}
-
-	/* not given any topic to look for, so display general help */
-	if (topic==NULL)
-	{
-		/* allowed high-level help */
-		if (wiz)
-		{
-			/* search for best help file */
-			x = makepath(WIZHELP, "/", "general");
-			if (!access(x, 00)) found=TRUE;
-		}
-		/* no high-level help allowed, or available */
-		if (!found)
-		{
-			/* search for normal help */
-			x = makepath(HELPDIR, "/", "general");
-			if (!access(x, 00)) found=TRUE;
-		}
-		/* display message as to whether help was found */
-		if (found)
-			printfile(x);
-		else
-			printf(_("No general help available for talker commands.\n"));
-	}
-	/* a help topic was given */
-	else
-	{
-		/* find the command in the list */
-		c = table;
-		while (c->Command && strcasecmp(c->Command, topic)) c++;
-
-		/* do a permissions check if the command exists */
-		if (c->Command)
-		{
-			if ((rights & c->Rights) != c->Rights)
-			{
-				printf(_("Sorry, no help available on that subject.\n"));
-				return;
-			}
-		}
-
-		/* search for the high-level help file */
-		if (wiz)
-		{
-			/* search for the best topic help */
-			x = makepath(WIZHELP, "/", topic);
-			if (!access(x, 00)) found=TRUE;
-		}
-		/* no high-level help allowed, or available */
-		if (!found)
-		{
-			/* search for normal topic help */
-			x = makepath(HELPDIR, "/", topic);
-			if (!access(x, 00)) found=TRUE;
-		}
-
-		/* display the file, or appropriate help message */
-		if (found)
-			printfile(x);
-		else
-			printf(_("Sorry, no help available on that subject.\n"));
-	}
-}
-
-
-void credits(void)
-{
-	printf("The Milliways III bulletin board system.\n");
-	printf("(c) 1992 Arthur Dent (J.S.Mitchell)\n");
-	printf("\nLinux / Internet patches: Anarchy\n");
-	printf("Basis of new command parser: Anarchy\n");
-	printf("General Thanks to:\n");
-	printf("Arashi (ideas), Hobbit (spellings), Madsysop (for being annoying),\n");
-	printf("Fry (all those useful things that everyone seems to use, and MUD rooms),\n");
-	printf("Finnw (I/O multiplexing, dynamic hash tables),\n");
-	printf("FireFury (debugging code, IPC abstraction),\n");
-	printf("Cmckenna (MUD rooms, gag filters, help text updates),\n");
-	printf("Dez (man page style help, ideas, testing),\n");
-	printf("Pwb (RPM packaging, UTF-8 compatibility hacks),\n");
-	printf("Psycodom (Fixups for IPC, JS, locale conversions, buffer overflows)\n");
-	printf("\n");
-}
-
 int idle(int fd, int millis)
 {
 	static int in_idle = 0;
@@ -1473,17 +1380,6 @@
 	return(c);
 }
 
-char *duplstr(char *text)
-{
-	char *c;
-	int i;
-	c=(char *)malloc(strlen(text)+1);
-	for (i=0;i<strlen(text);i++)
-		c[i]=tolower(text[i]);
-	c[strlen(text)]=0;
-	return(c);
-}
-
 static char *strip_commandname(char *line)
 {
 	char *l2 = strdup(line);
@@ -2096,11 +1992,6 @@
 	return(NULL);
 }
 
-char *dummy_list(const char *text, int state)
-{
-	return(NULL);
-}
-
 void c_version(CommandList *cm, int argc, char **argv, char *args)
 {
 #ifdef RELEASE

Added: trunk/src/main.h
===================================================================
--- trunk/src/main.h	                        (rev 0)
+++ trunk/src/main.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,28 @@
+#ifndef MAIN_H
+#define MAIN_H
+
+void close_down(int exitmode, char *sourceuser, char *reason);
+void display_message(char *text, int beeps, int newline);
+void printfile(char *filename);
+void broadcast_onoffcode(int code, int method, const char *sourceuser, const char *reason);
+void reset_timeout(int secs);
+int idle(int fd, int millis);
+void set_rights(void);
+char *dupstr(char *text, char *prepend);
+
+char *part_who_talk(const char *text, int status);
+char *part_who(const char *text, int status);
+char *part_user(const char *text, int status);
+char *part_comm_search(const char *text, int status);
+char *part_comm_folder(const char *text, int status);
+char *part_comm_user(const char *text, int status);
+char *part_comm_mesg(const char *text, int status);
+char *list_commands(const char *text, int state);
+char *list_chat_commands(const char *text, int state);
+char *find_folder(const char *text, int state);
+
+void devel_msg(char *func, char *fmt, ...);
+
+int disable_rl(int savetext);
+
+#endif /* MAIN_H */

Modified: trunk/src/mesg.c
===================================================================
--- trunk/src/mesg.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/mesg.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -5,11 +5,12 @@
 #include <string.h>
 #include <stdarg.h>
 #include "bb.h"
-#include "proto.h"
 #include "talker_privs.h"
 #include "special.h"
 #include "ipc.h"
 #include "user.h"
+#include "perms.h"
+#include "files.h"
 
 char *get_pipe_name(int pid)
 {

Added: trunk/src/mesg.h
===================================================================
--- trunk/src/mesg.h	                        (rev 0)
+++ trunk/src/mesg.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,13 @@
+#ifndef MESG_H
+#define MESG_H
+
+#include "bb.h"
+
+void broadcast(int state, char *fmt, ...);
+void create_pipe(void);
+char *get_pipe_name(int pid);
+void inform_of_mail(char *to);
+void postinfo(struct person *who, struct folder *fol, struct Header *mesg);
+void send_mesg(char *from, char *to, char *text, int wiz);
+
+#endif /* MESG_H */

Modified: trunk/src/mod.c
===================================================================
--- trunk/src/mod.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/mod.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -9,7 +9,79 @@
 #include "bb.h"
 #include "files.h"
 #include "strings.h"
+#include "read.h"
+#include "locking.h"
 
+static void add_message(struct folder *fold, struct Header *head, char *text)
+{
+	char fullpath[PATHSIZE];
+	int modindex,modtext;
+	
+	/* files for general public to read */
+	sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,INDEX_END);
+	if ((modindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
+		{perror(fullpath);exit(-1);}
+	sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,TEXT_END);
+	if ((modtext=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
+		{perror(fullpath);exit(-1);}
+	Lock_File(modindex);
+	Lock_File(modtext);
+	head->Ref=fold->last;
+	head->datafield=lseek(modtext,0,2);
+	if (write(modindex,head,sizeof(*head))<0) {perror("mod: writehead");}
+	if (write(modtext,text,head->size)<0) {perror("mod: write text");}
+	
+	Unlock_File(modtext);
+	Unlock_File(modindex);
+	close(modtext);
+	close(modindex);
+}
+
+static void put_back(struct folder *fold, struct Header *head, char *text)
+{
+	char fullpath[PATHSIZE];
+	int newindex,newtext;
+	
+		/* files to put messages to be approved later */
+	sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,INDEX_END,MOD_END);
+	if ((newindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
+		{perror(fullpath);exit(-1);}
+	sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,TEXT_END,MOD_END);
+	if ((newtext=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
+		{perror(fullpath);exit(-1);}
+	Lock_File(newindex);
+	Lock_File(newtext);
+	head->datafield=lseek(newtext,0,2);
+	head->Ref=0;
+	write(newindex,head,sizeof(*head));
+	write(newtext,text,head->size);
+	Unlock_File(newtext);
+	Unlock_File(newindex);
+	close(newindex);
+	close(newtext);
+}
+
+static void store(struct folder *fold, struct Header *head, char *text)
+{
+	int afile;
+	char buff[128];
+	char fullpath[PATHSIZE];
+	time_t head_date;
+	
+	sprintf(fullpath,"%s/%s",STATEDIR,"mod.save");
+	head_date = (time_t)head->date;
+	if ((afile=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
+		{perror(fullpath);exit(-1);}
+	
+	Lock_File(afile);
+	sprintf(buff,_("\nMessage in folder %s\nFrom: %s\nTo: %s\nSubject: %s\nDate: %s"),
+	        fold->name, head->from, head->to, head->subject, ctime(&head_date));
+	write(afile,buff,strlen(buff));
+	write(afile,text,head->size+1);
+	Unlock_File(afile);
+	close(afile);
+}
+
 void moderate(void)
 {
 	char fullpath[PATHSIZE],oldpath[PATHSIZE];
@@ -92,72 +164,3 @@
 	close(f_file);
 }
 
-void put_back(struct folder *fold, struct Header *head, char *text)
-{
-	char fullpath[PATHSIZE];
-	int newindex,newtext;
-	
-		/* files to put messages to be approved later */
-	sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,INDEX_END,MOD_END);
-	if ((newindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
-		{perror(fullpath);exit(-1);}
-	sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,TEXT_END,MOD_END);
-	if ((newtext=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
-		{perror(fullpath);exit(-1);}
-	Lock_File(newindex);
-	Lock_File(newtext);
-	head->datafield=lseek(newtext,0,2);
-	head->Ref=0;
-	write(newindex,head,sizeof(*head));
-	write(newtext,text,head->size);
-	Unlock_File(newtext);
-	Unlock_File(newindex);
-	close(newindex);
-	close(newtext);
-}
-
-void add_message(struct folder *fold, struct Header *head, char *text)
-{
-	char fullpath[PATHSIZE];
-	int modindex,modtext;
-	
-	/* files for general public to read */
-	sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,INDEX_END);
-	if ((modindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
-		{perror(fullpath);exit(-1);}
-	sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,TEXT_END);
-	if ((modtext=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
-		{perror(fullpath);exit(-1);}
-	Lock_File(modindex);
-	Lock_File(modtext);
-	head->Ref=fold->last;
-	head->datafield=lseek(modtext,0,2);
-	if (write(modindex,head,sizeof(*head))<0) {perror("mod: writehead");}
-	if (write(modtext,text,head->size)<0) {perror("mod: write text");}
-	
-	Unlock_File(modtext);
-	Unlock_File(modindex);
-	close(modtext);
-	close(modindex);
-}
-
-void store(struct folder *fold, struct Header *head, char *text)
-{
-	int afile;
-	char buff[128];
-	char fullpath[PATHSIZE];
-	time_t head_date;
-	
-	sprintf(fullpath,"%s/%s",STATEDIR,"mod.save");
-	head_date = (time_t)head->date;
-	if ((afile=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
-		{perror(fullpath);exit(-1);}
-	
-	Lock_File(afile);
-	sprintf(buff,_("\nMessage in folder %s\nFrom: %s\nTo: %s\nSubject: %s\nDate: %s"),
-	        fold->name, head->from, head->to, head->subject, ctime(&head_date));
-	write(afile,buff,strlen(buff));
-	write(afile,text,head->size+1);
-	Unlock_File(afile);
-	close(afile);
-}

Added: trunk/src/mod.h
===================================================================
--- trunk/src/mod.h	                        (rev 0)
+++ trunk/src/mod.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,6 @@
+#ifndef MOD_H
+#define MOD_H
+
+void moderate(void);
+
+#endif /* MOD_H */

Modified: trunk/src/new.c
===================================================================
--- trunk/src/new.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/new.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -12,6 +12,12 @@
 #include "alarm.h"
 #include "incoming.h"
 #include "strings.h"
+#include "talker.h"
+#include "files.h"
+#include "perms.h"
+#include "read.h"
+#include "main.h"
+#include "add.h"
 
 extern int remote;
 extern int busy;
@@ -69,43 +75,7 @@
 	close(file);
 }
 
-void new(struct person *user)
-{		
-	struct folder *data;	
-	int folderfile;
-	int folnum=0;
-	
-	data=(struct folder *)malloc(sizeof(*data));
-
-	if (nofolders())
-	{
-		printf(_("There are no folders to read !\n"));
-		free(data);
-		return;
-	}	
-	folderfile=openfolderfile(O_RDONLY);
-	while (get_folder_entry(folderfile,data))
-	{
-		if (data->status&1 /*active*/
-		&& allowed_r(data,user) /* allowed to read */ 
-	    	&& get_subscribe(user,folnum)  /* currently subscribed */
-		&& !(data->last<data->first || data->last==0)
-		&& !(data->last<=user->lastread[folnum])) 
-		{
-			if (!remote)
-			{
-				printf(_("Scanning folder %-*s\r"),FOLNAMESIZE,data->name);
-				fflush(stdout);
-			}
-			if (read_new(user,data,folnum)) break;
-		}
-		folnum++;
-	}
-	free(data);
-	close(folderfile);
-}
-
-int read_new(struct person *user, struct folder *data, int folnum)
+static int read_new(struct person *user, struct folder *data, int folnum)
 {
 	int indexfile,datafile;
 	long posn;
@@ -201,6 +171,42 @@
 	return(0);
 }
 
+void new(struct person *user)
+{		
+	struct folder *data;	
+	int folderfile;
+	int folnum=0;
+	
+	data=(struct folder *)malloc(sizeof(*data));
+
+	if (nofolders())
+	{
+		printf(_("There are no folders to read !\n"));
+		free(data);
+		return;
+	}	
+	folderfile=openfolderfile(O_RDONLY);
+	while (get_folder_entry(folderfile,data))
+	{
+		if (data->status&1 /*active*/
+		&& allowed_r(data,user) /* allowed to read */ 
+	    	&& get_subscribe(user,folnum)  /* currently subscribed */
+		&& !(data->last<data->first || data->last==0)
+		&& !(data->last<=user->lastread[folnum])) 
+		{
+			if (!remote)
+			{
+				printf(_("Scanning folder %-*s\r"),FOLNAMESIZE,data->name);
+				fflush(stdout);
+			}
+			if (read_new(user,data,folnum)) break;
+		}
+		folnum++;
+	}
+	free(data);
+	close(folderfile);
+}
+
 void latest(struct person *user)
 {
 	int ffile,ifile;

Added: trunk/src/new.h
===================================================================
--- trunk/src/new.h	                        (rev 0)
+++ trunk/src/new.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,10 @@
+#ifndef NEW_H
+#define NEW_H
+
+#include "bb.h"
+
+void list_new_items(struct person *user, int flag);
+void new(struct person *user);
+void latest(struct person *user);
+
+#endif /* NEW_H */

Modified: trunk/src/newmain.c
===================================================================
--- trunk/src/newmain.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/newmain.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -14,7 +14,25 @@
 #include "Parse.h"
 #include "iconv.h"
 #include "strings.h"
-
+#include "edit.h"
+#include "main.h"
+#include "perms.h"
+#include "files.h"
+#include "folders.h"
+#include "new.h"
+#include "user.h"
+#include "read.h"
+#include "edit.h"
+#include "colour.h"
+#include "who.h"
+#include "mod.h"
+#include "mesg.h"
+#include "topten.h"
+#include "tidyup.h"
+#include "getpass.h"
+#include "add.h"
+#include "init.h"
+#include "talker.h"
 #include "talker_privs.h"
 #include "special.h"
 #include "ipc.h"
@@ -44,6 +62,81 @@
 /* prototype */
 void help_list(CommandList *cm, unsigned int hidestuff);
 
+static void help(char *topic, int wiz)
+{
+	CommandList	*c;
+	char		*x = NULL;
+	int		found=FALSE;
+
+	if (topic!=NULL && (strchr(topic,'.')!=NULL || strchr(topic,'/')!=NULL))
+	{
+		printf(_("Sorry, no help available on that subject.\n"));
+		return;
+	}
+
+	/* not given any topic to look for, so display general help */
+	if (topic==NULL)
+	{
+		/* allowed high-level help */
+		if (wiz)
+		{
+			/* search for best help file */
+			x = makepath(WIZHELP, "/", "general");
+			if (!access(x, 00)) found=TRUE;
+		}
+		/* no high-level help allowed, or available */
+		if (!found)
+		{
+			/* search for normal help */
+			x = makepath(HELPDIR, "/", "general");
+			if (!access(x, 00)) found=TRUE;
+		}
+		/* display message as to whether help was found */
+		if (found)
+			printfile(x);
+		else
+			printf(_("No general help available for talker commands.\n"));
+	}
+	/* a help topic was given */
+	else
+	{
+		/* find the command in the list */
+		c = table;
+		while (c->Command && strcasecmp(c->Command, topic)) c++;
+
+		/* do a permissions check if the command exists */
+		if (c->Command)
+		{
+			if ((rights & c->Rights) != c->Rights)
+			{
+				printf(_("Sorry, no help available on that subject.\n"));
+				return;
+			}
+		}
+
+		/* search for the high-level help file */
+		if (wiz)
+		{
+			/* search for the best topic help */
+			x = makepath(WIZHELP, "/", topic);
+			if (!access(x, 00)) found=TRUE;
+		}
+		/* no high-level help allowed, or available */
+		if (!found)
+		{
+			/* search for normal topic help */
+			x = makepath(HELPDIR, "/", topic);
+			if (!access(x, 00)) found=TRUE;
+		}
+
+		/* display the file, or appropriate help message */
+		if (found)
+			printfile(x);
+		else
+			printf(_("Sorry, no help available on that subject.\n"));
+	}
+}
+
 void c_help(CommandList *cm, int argc, char **argv, char *args)
 {
 	if (argc>1)
@@ -686,6 +779,24 @@
 	time_on(user->timeused+(time(0) - loggedin));
 }
 
+static void credits(void)
+{
+	printf("The Milliways III bulletin board system.\n");
+	printf("(c) 1992 Arthur Dent (J.S.Mitchell)\n");
+	printf("\nLinux / Internet patches: Anarchy\n");
+	printf("Basis of new command parser: Anarchy\n");
+	printf("General Thanks to:\n");
+	printf("Arashi (ideas), Hobbit (spellings), Madsysop (for being annoying),\n");
+	printf("Fry (all those useful things that everyone seems to use, and MUD rooms),\n");
+	printf("Finnw (I/O multiplexing, dynamic hash tables),\n");
+	printf("FireFury (debugging code, IPC abstraction),\n");
+	printf("Cmckenna (MUD rooms, gag filters, help text updates),\n");
+	printf("Dez (man page style help, ideas, testing),\n");
+	printf("Pwb (RPM packaging, UTF-8 compatibility hacks),\n");
+	printf("Psycodom (Fixups for IPC, JS, locale conversions, buffer overflows)\n");
+	printf("\n");
+}
+
 void c_credits(CommandList *cm, int argc, char **argv, char *args)
 {
 	credits();

Modified: trunk/src/perms.c
===================================================================
--- trunk/src/perms.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/perms.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -10,6 +10,7 @@
 #include <stdarg.h>
 
 #include "bb.h"
+#include "perms.h"
 
 int allowed_r(struct folder *fol, struct person *usr)
 /* permission to read from folder */

Added: trunk/src/perms.h
===================================================================
--- trunk/src/perms.h	                        (rev 0)
+++ trunk/src/perms.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,46 @@
+#ifndef PERMS_H
+#define PERMS_H
+
+#include "bb.h"
+
+int u_god(int user);
+int u_mod(int user);
+int u_mod(int user);
+int u_reg(int user);
+int u_ban(int user);
+int u_del(int user);
+int u_mesg(int user);
+int u_beep(int user);
+int u_inform(int user);
+
+void mwlog(char *fmt, ...);
+
+char user_stats(char *string, char stat);
+char mesg_stats(char *string, char stat);
+
+void show_user_stats(unsigned char stat, char *tmp, int flag);
+void show_mesg_stats(unsigned char stat, char *tmp, int flag);
+void show_fold_groups(char stat, char *tmp, int flag);
+void show_fold_stats(char stat, char *tmp, int flag);
+
+int allowed_r(struct folder *fol, struct person *usr);
+int allowed_w(struct folder *fol, struct person *usr);
+
+int is_private(struct folder *fol, struct person *usr);
+int is_moderated(struct folder *fol, struct person *usr);
+
+char folder_stats(char *string, char stat);
+char folder_groups(char *string, char stat);
+
+void set_subscribe(struct person *user,int folder,int status);
+int get_subscribe(struct person *user, int folder);
+
+int f_active(int stat);
+int f_r_unreg(int stat);
+int f_w_unreg(int stat);
+int f_r_reg(int stat);
+int f_w_reg(int stat);
+int f_private(int stat);
+int f_moderated(int stat);
+
+#endif

Deleted: trunk/src/proto.h
===================================================================
--- trunk/src/proto.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/proto.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,251 +0,0 @@
-/* proto.h
- * Prototypes of all nonstatic functions.
- */
-
-#ifndef PROTO_H
-#define PROTO_H
-
-#include <sys/types.h>
-#include <stdio.h> /* for FILE */
-
-#include "bb.h"
-
-/* user.c */
-char *getmylogin(void);
-void update_user(struct person *record, int32_t userposn);
-void fetch_user(struct person *record, int32_t userposn);
-void login_ok(struct person *usr, int32_t *userposn, int *autochat);
-void get_login(char *name, int autochat);
-void strip_name(char *string);
-int get_person(int file, struct person *tmp);
-int old_usr(struct person *usr);
-int new_usr(struct person *usr, char *name, int32_t *userposn);
-void set_defaults(struct person *tmp);
-void pick_salt(char *salt);
-void list_users(int newonly);
-void list_users_since(long date);
-void list_users_flags(int flags, int type, int inv);
-void search(char *args, char *ptr);
-/* main.c */
-void set_rights(void);
-void close_down(int exitmode, char *sourceuser, char *reason);
-void printfile(char *filename);
-void help(char *args, int wiz);
-void credits(void);
-int idle(int fd, int millis);
-void display_message(char *text, int beeps, int newline);
-void set_prompt(void);
-void accept_command(char *comm);
-void accept_line(char *line);
-void time_out(void *idle_count_p);
-void reset_timeout(int secs);
-char *dupstr(char *text, char *prepend);
-char *duplstr(char *text);
-char *list_commands(const char *text, int state);
-char *list_chat_commands(const char *text, int state);
-char *find_folder(const char *text, int state);
-char *part_who(const char *text, int status);
-char *part_who_talk(const char *text, int status);
-char *part_user(const char *text, int status);
-char *part_comm_user(const char *text, int status);
-char *part_comm_search(const char *text, int status);
-char *part_comm_folder(const char *text, int status);
-char *part_comm_mesg(const char *text, int status);
-char *dummy_list(const char *text, int state);
-void enable_rl();
-int disable_rl(int savetext);
-void devel_msg(char *func, char *fmt, ...);
-void broadcast_onoffcode(int code, int method, const char *sourceuser, const char *reason);
-/* read.c */
-int get_data(int afile, struct Header *tmp);
-void display_article(struct Header *tmp, int datafile);
-int read_msg(int folnum, int msgnum, struct person *user);
-void ls(int folnum, struct person *user, int many);
-void more(char *buff, int size);
-int get_mesg_header(struct folder *data, int msgnum, struct Header *head);
-/* add.c */
-int add_msg(int folnum, struct person *user, int replyto);
-/* folders.c */
-void add_folder(void);
-void auto_subscribe(int folnum, int state);
-/* new.c */
-void list_new_items(struct person *user, int flag);
-void new(struct person *user);
-int read_new(struct person *user, struct folder *data, int folnum);
-void latest(struct person *user);
-/* perms.c */
-int allowed_r(struct folder *fol, struct person *usr);
-int is_private(struct folder *fol, struct person *usr);
-int is_moderated(struct folder *fol, struct person *usr);
-int allowed_w(struct folder *fol, struct person *usr);
-int u_ban(int user);
-int u_del(int user);
-int u_god(int user);
-int u_inform(int user);
-int u_mesg(int user);
-int u_beep(int user);
-int u_mod(int user);
-int u_reg(int user);
-int f_active(int stat);
-int f_r_unreg(int stat);
-int f_w_unreg(int stat);
-int f_r_reg(int stat);
-int f_w_reg(int stat);
-int f_private(int stat);
-int f_moderated(int stat);
-char user_stats(char *string, char stat);
-char mesg_stats(char *string, char stat);
-char folder_stats(char *string, char stat);
-char folder_groups(char *string, char stat);
-void show_user_stats(unsigned char stat, char *tmp, int flag);
-void show_mesg_stats(unsigned char stat, char *tmp, int flag);
-void show_fold_stats(char stat, char *tmp, int flag);
-void show_fold_groups(char stat, char *tmp, int flag);
-void mwlog(char *fmt, ...);
-int get_subscribe(struct person *user, int folder);
-void set_subscribe(struct person *user, int folder, int status);
-/* edit.c */
-void edit_user(char *args, char *name);
-void edit_all(struct person *usr);
-void edit_folder(char *args, char *name);
-void edit_contact(void);
-void users_lastread(int folnum);
-void mesg_edit(char *args, char *foldername, int msgno, struct person *usr);
-void time_on(long u);
-void show_change(char *old, char *new, char *fmt, ...);
-
-/* mod.c */
-void moderate(void);
-void put_back(struct folder *fold, struct Header *head, char *text);
-void add_message(struct folder *fold, struct Header *head, char *text);
-void store(struct folder *fold, struct Header *head, char *text);
-/* locking.c */
-void Lock_File(int f);
-void Unlock_File(int f);
-/* echo.c */
-void echo_on(void);
-void echo_off(void);
-void force_line_mode(void);
-void save_terminal(void);
-void fix_terminal(void);
-/* getpass.c */
-char *get_pass(char *p);
-/* filter.c */
-void tidy_string(char *buff);
-void filter_returns(char *buff);
-/* mesg.c */
-void create_pipe(void);
-char *get_pipe_name(int pid);
-void send_mesg(char *from, char *to, char *text, int wiz);
-void inform_of_mail(char *to);
-void postinfo(struct person *who, struct folder *fol, struct Header *mesg);
-void broadcast(int state, char *fmt, ...);
-/* strings.c (see also strings.h) */
-void get_str(char *string, int size);
-void read2cr(void);
-int getachar(void);
-void strip_str(char *string);
-char *buildpath(char *a, char *b, char *c, char *d);
-#define makepath(a,b,c) (buildpath(HOMEPATH,a,b,c))
-int err_open(char *path, int type, int mode);
-char *mw_fgets(char *string, int size, FILE *fp);
-/* files.c (see also files.h) */
-int openfolderfile(int mode);
-int nofolders(void);
-int openuserfile(int flags);
-void write_usr(struct person *record, int32_t *userposn);
-int openwhofile(int mode);
-void who_add(int pid, int32_t posn);
-void create_folder_file(void);
-int foldernumber(char *name);
-int get_folder_entry(int file, struct folder *tmp);
-int get_folder_number(struct folder *fol, int num);
-/* special.c
-   prototypes now in "special.h" */
-/* Parse.c */
-int ParseLine(char *line, char *argv[]);
-int BoolOpt(const char *n);
-char *remove_first_word(char *args);
-/*int DoCommand(char *input, const CommandList *cm);*/
-void InitParser(void);
-int command_compare(char *input, char *comm);
-/*void help_list(CommandList *c);*/
-/* init.c */
-void LoadInitFile(char *);
-int perms_drop(void);
-void perms_restore(void);
-/* talker_privs.c */
-unsigned long cm_flags(unsigned long cm, unsigned long flags, int mode);
-char *display_cmflags(unsigned long cm);
-void show_chatmodes(unsigned long cm, char *tmp, int flag);
-void show_protection(unsigned long cm, unsigned long cp, char *tmp, int ourapl);
-unsigned long cm_setbycode(unsigned long stat, char *string);
-unsigned long chatmode_describe(unsigned long old, unsigned long new, int ourapl, int theirapl, const char *from);
-int gag_code(char *str);
-char *gag_type(int type);
-char *ungag_name(unsigned long chatmode);
-int flag_match(unsigned long val, char *filter);
-unsigned long gag_describe(unsigned long old, unsigned long new);
-unsigned long cp_flags(unsigned long cm, unsigned long flags, int mode);
-char *display_cpflags(unsigned long cm);
-void show_chatprivs(unsigned long cp, char *tmp, int flag);
-unsigned long cp_setbycode(unsigned long stat, char *string);
-char *part_gag_filter(const char *text, int state);
-/* colour.c */
-char *colour(char *text, int *concealed);
-void colour_load(char *file, int quiet);
-void colour_free(void);
-void init_colour(void);
-char *get_colour(void);
-void destroy_colours(void);
-/* bork.c */
-/*char *apply_bork(char *text, struct pattern *list);*/
-/* talker.c */
-void t_chaton(void);
-void chat_say(char *text);
-void chat_sayto(char *to,char *text, int exclude);
-void set_talk_rights(void);
-void talk_send(char *text, int state, int channel);
-void talk_single(char *to, char *text);
-void talk_sayto(char *text, char *to, int channel, int exclude);
-void apply_gag(char *text);
-void strip_quote(char *a);
-/* who.c */
-void who_delete(int pid);
-void who_list(int mode);
-void what_list(void);
-int get_pid(char *name);
-void check_copies(int32_t where);
-char *itime(unsigned long t);
-int32_t get_who_userposn(int pid);
-/* talker.c */
-struct IgnoreList *is_ignored(char *name, struct IgnoreList **prev);
-int screen_h(void);
-int screen_w(void);
-void sendipc(char *to, char *text, int broadcast);
-void sendrpc(char *to, char *type, char *text, int broadcast);
-/* script.c */
-struct mstack;
-void script_init();
-void DestroyVariables(int debug);
-void DestroyAllFunctions(int debug);
-void ScriptCleanup(void);
-void LoadFunction(char *funcname, char *header, FILE *file, int *lineno, const char *filename, int flags);
-int StartEventThread(char *funcname, struct mstack *mesg);
-int ExecEvent(char *funcname, char *text, char *evtype, char *from, int pre);
-int ExecEvent2(char *script, char *event, char *who, int pre, int numargs, char *aargs[]);
-void Doscript(char *);
-void ListScript(char *name);
-void ListVars(char *search);
-void scr_helpfile(char *args);
-void scr_helplist(void);
-char *list_script(const char *text, int state);
-/* topten.c */
-void topten(int argc, char **argv);
-/* tidyup.c */
-void tidyup(int argc, char **argv);
-/* alias.c */
-char *list_bind(const char *text, int state);
-char *list_alias(const char *text, int state);
-
-#endif /* PROTO_H */

Modified: trunk/src/read.c
===================================================================
--- trunk/src/read.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/read.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -10,6 +10,11 @@
 #include <string.h>
 #include "bb.h"
 #include "strings.h"
+#include "perms.h"
+#include "read.h"
+#include "files.h"
+#include "talker.h"
+#include "echo.h"
 
 extern int remote;
 extern FILE *output;

Added: trunk/src/read.h
===================================================================
--- trunk/src/read.h	                        (rev 0)
+++ trunk/src/read.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,13 @@
+#ifndef READ_H
+#define READ_H
+
+#include "bb.h"
+
+int get_mesg_header(struct folder *data, int msgnum, struct Header *head);
+int get_data(int afile, struct Header *tmp);
+void more(char *buff, int size);
+void display_article(struct Header *tmp, int datafile);
+int read_msg(int folnum, int msgnum, struct person *user);
+void ls(int folnum, struct person *user, int many);
+
+#endif /* READ_H */

Modified: trunk/src/rooms.c
===================================================================
--- trunk/src/rooms.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/rooms.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -8,7 +8,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include "bb.h"
-#include "proto.h"
 #include <signal.h>
 #include "talker_privs.h"
 #include "talker.h"
@@ -17,6 +16,8 @@
 #include "strings.h"
 #include "ipc.h"
 #include "sqlite.h"
+#include "user.h"
+#include "main.h"
 
 extern unsigned long rights;
 #define MAX_ARGC 128

Modified: trunk/src/rooms.h
===================================================================
--- trunk/src/rooms.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/rooms.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,5 +1,11 @@
-/* rooms.c */
+#ifndef ROOMS_H
+#define ROOMS_H
+
+#include "bb.h"
+
 void RoomInit(struct room *room);
 void RoomDestroy(struct room *room);
 int LoadRoom(struct room *room, int num);
 int ChangeRoom(char *room, int quiet);
+
+#endif /* ROOMS_H */

Modified: trunk/src/scrcomplete.h
===================================================================
--- trunk/src/scrcomplete.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/scrcomplete.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,6 +1,13 @@
+#ifndef SCRCOMPLETE_H
+#define SCRCOMPLETE_H
 
+#include <stddef.h>
+#include "main.h"
+#include "talker_privs.h"
+#include "script.h"
+#include "alias.h"
+
 FuncNames scrtc[]={
-
 {"talkname"	,part_who_talk},
 {"whoname"	,part_who},
 {"username"	,part_user},
@@ -12,3 +19,5 @@
 {"null"		,NULL},
 {NULL		,NULL}
 };
+
+#endif /* SCRCOMPLETE_H */

Modified: trunk/src/script.c
===================================================================
--- trunk/src/script.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/script.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -12,12 +12,13 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include "bb.h"
-#include "proto.h"
 #include "talker_privs.h"
 #include "rooms.h"
 #include "alarm.h"
 #include "strings.h"
 #include "expand.h"
+#include "talker.h"
+#include "init.h"
 
 #include "alias.h"
 #include "script_inst.h"
@@ -73,7 +74,7 @@
 static char	       *homedir = NULL;
 static size_t		homelen = 0;
 
-void script_init()
+void script_init(void)
 {
 	hash_setup();
 	VAR_NEWLIST(&var_list);

Modified: trunk/src/script.h
===================================================================
--- trunk/src/script.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/script.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -254,5 +254,19 @@
 void var_key_dup(var_op_t *op);
 
 int ExecScript(char *name, var_list_t *args, int bound);
+int ExecEvent(char *script, char *text, char *event, char *who, int pre);
+int ExecEvent2(char *script, char *event, char *who, int pre, int numargs, char *aargs[]);
 
+void ListScript(char *name);
+void ListVars(char *search);
+void ScriptCleanup(void);
+void DestroyAllFunctions(int debug);
+void DestroyFunction(char *funcname);
+void DestroyVariables(int debug);
+
+void script_init(void);
+
+void scr_helpfile(char *args);
+void scr_helplist(void);
+
 #endif /* SCRIPT_H */

Modified: trunk/src/script_inst.c
===================================================================
--- trunk/src/script_inst.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/script_inst.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -23,6 +23,8 @@
 #include "ipc.h"
 #include "iconv.h"
 #include "files.h"
+#include "perms.h"
+#include "main.h"
 
 extern struct person *user;
 extern long userposn;

Modified: trunk/src/script_inst.h
===================================================================
--- trunk/src/script_inst.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/script_inst.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef SCRIPT_INST_H
+#define SCRIPT_INST_H
+
 #include <stdio.h>
 #include "script.h"
 
@@ -50,4 +53,10 @@
 void scr_version( struct code *, int, char **);
 void scr_wholist( struct code *, int, char **);
 
+int isanumul(char *a, unsigned long *result, int onlydecimal);
+int isanum(char *a, int *result, int onlydecimal);
+
 extern Instruction inst_table[];
+
+#endif /* SCRIPT_INST_H */
+

Modified: trunk/src/sort.h
===================================================================
--- trunk/src/sort.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/sort.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,8 @@
+#ifndef SORT_H
+#define SORT_H
+
+#include "bb.h"
+
 struct listing
 {
 	char name[NAMESIZE+1];
@@ -7,3 +12,5 @@
 };
 
 struct listing *Sort(struct listing *head);
+
+#endif /* SORT_H */

Modified: trunk/src/special.h
===================================================================
--- trunk/src/special.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/special.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef SPECIAL_H
+#define SPECIAL_H
+
 unsigned short set_special(char *string, unsigned short stat);
 void show_special(unsigned short stat, char *tmp, int flag);
 int s_coventry(unsigned short stat);
@@ -15,3 +18,5 @@
 int s_devel(unsigned short stat);
 int s_fixedcontact(unsigned short stat);
 int s_nolinewrap(unsigned short stat);
+
+#endif /* SPECIAL_H */

Modified: trunk/src/sqlite.h
===================================================================
--- trunk/src/sqlite.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/sqlite.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef SQLITE_H
+#define SQLITE_H
+
 /* Functions to access and interact with SQLite */
 
 struct db_data {
@@ -29,3 +32,5 @@
 void userdb_set(const char *table, const char *user, const char *opt, const char *arg);
 char * db_room_get(int room, const char *opt);
 void db_room_set(int room, const char *opt, const char *arg);
+
+#endif /* SQLITE_H */

Modified: trunk/src/strings.c
===================================================================
--- trunk/src/strings.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/strings.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -8,8 +8,8 @@
 #include <errno.h>
 #include <stdarg.h>
 #include "bb.h"
-#include "proto.h"
 #include "strings.h"
+#include "main.h"
 
 #define FALSE 	0
 #define TRUE	!FALSE

Modified: trunk/src/strings.h
===================================================================
--- trunk/src/strings.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/strings.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef STRINGS_H
+#define STRINGS_H
+
 #define CMD_TEXT	0	/* Interpreted depending on mode/prefix      */
 #define CMD_BOARD	1	/* Always a board command, used by BOARDEXEC */
 #define CMD_TALKER	2	/* Always a talker command, used by EXEC     */
@@ -23,3 +26,14 @@
 
 void escprintf(char *szFormat, ...);
 char *strip_colours(const char *text);
+void strip_str(char *string);
+void get_str(char *string, int size);
+
+char *buildpath(char *a, char *b, char *c, char *d);
+#define makepath(a,b,c) (buildpath(HOMEPATH,a,b,c))
+
+int err_open(char *path,int type,int mode);
+int getachar(void);
+void read2cr(void);
+
+#endif /* STRINGS_H */

Modified: trunk/src/talker.c
===================================================================
--- trunk/src/talker.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/talker.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -8,21 +8,26 @@
 #include <termcap.h>
 #include <sys/types.h>
 #include <regex.h>
+#include <sqlite3.h>
 
 #include "bb.h"
 #include "Parse.h"
 #include "talker_privs.h"
 #include "special.h"
-#include "proto.h"
 #include "talker.h"
 #include "gags.h"
 #include "strings.h"
 #include "special.h"
 #include "script.h"
+#include "script_inst.h"
 #include "js.h"
 #include "files.h"
 #include "sqlite.h"
-#include <sqlite3.h>
+#include "perms.h"
+#include "who.h"
+#include "main.h"
+#include "init.h"
+#include "echo.h"
 
 #include "rooms.h"
 #include "ipc.h"
@@ -40,17 +45,6 @@
 extern Alias force_list;
 extern Alias shutdown_list;
 
-/* extra protos */
-void help_list(CommandList *cm, unsigned int hidestuff);
-void set_rights(void);
-void DestroyFunction(char *);
-void LoadInitFile(char *);
-void scr_helpfile(char *args);
-void scr_helplist(void);
-int isanum(char *a, int *result, int onlydecimal);
-int isanumul(char *a, unsigned long *result, int onlydecimal);
-
-
 extern int busy; /* if true dont display messages  i.e. during new/write */
 extern unsigned long rights;
 

Modified: trunk/src/talker.h
===================================================================
--- trunk/src/talker.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/talker.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef TALKER_H
+#define TALKER_H
+
 #include "Parse.h"
 
 /* talker.c */
@@ -71,3 +74,14 @@
 
 void enter_talker(int logontype);
 void talk_help(char *args);
+int screen_h(void);
+int screen_w(void);
+
+struct IgnoreList *is_ignored(char *name, struct IgnoreList **prev);
+
+void sendipc(char *to, char *text, int broadcast);
+void sendrpc(char *to, char *type, char *text, int broadcast);
+
+void strip_quote(char *a);
+
+#endif /* TALKER_H */

Modified: trunk/src/talker_privs.c
===================================================================
--- trunk/src/talker_privs.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/talker_privs.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -4,8 +4,8 @@
 #include "talker_privs.h"
 #include "talker.h"
 #include "bb.h"
-#include "proto.h"
 #include "gags.h"
+#include "main.h"
 
 #define FALSE 0
 #define TRUE !FALSE

Modified: trunk/src/talker_privs.h
===================================================================
--- trunk/src/talker_privs.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/talker_privs.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,5 @@
+#ifndef TALKER_PRIVS_H
+#define TALKER_PRIVS_H
 
 /* modes for cm_flags */
 #define CM_MODE_SET	1
@@ -45,3 +47,25 @@
 #define CP_UNUSED1	0x00010000
 
 #define CP_PROTSHIFT	13
+
+unsigned long cm_flags(unsigned long cm, unsigned long flags, int mode);
+unsigned long cm_setbycode(unsigned long stat, char *string);
+unsigned long cp_setbycode(unsigned long stat, char *string);
+
+char *display_cpflags(unsigned long cm);
+char *display_cmflags(unsigned long cm);
+
+void show_chatmodes(unsigned long cm, char *tmp, int flag);
+void show_chatprivs(unsigned long cp, char *tmp, int flag);
+void show_protection(unsigned long cm, unsigned long cp, char *tmp, int ourapl);
+
+int gag_code(char *str);
+char *gag_type(int type);
+char *ungag_name(unsigned long chatmode);
+int flag_match(unsigned long val, char *filter);
+
+char *part_gag_filter(const char *text, int state);
+unsigned long chatmode_describe(unsigned long old, unsigned long new, int ourapl, int theirapl, const char *from);
+
+#endif /* TALKER_PRIVS_H */
+

Modified: trunk/src/tidyup.c
===================================================================
--- trunk/src/tidyup.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/tidyup.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -7,6 +7,8 @@
 #include <fcntl.h>
 #include "bb.h"
 #include "strings.h"
+#include "files.h"
+#include "locking.h"
 
 #define NEW_END	".t"
 

Added: trunk/src/tidyup.h
===================================================================
--- trunk/src/tidyup.h	                        (rev 0)
+++ trunk/src/tidyup.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,6 @@
+#ifndef TIDYUP_H
+#define TIDYUP_H
+
+void tidyup(int argc, char **argv);
+
+#endif /* TIDYUP_H */

Modified: trunk/src/topten.c
===================================================================
--- trunk/src/topten.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/topten.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -9,6 +9,8 @@
 #include <stdlib.h>
 #include "bb.h"
 #include "sort.h"
+#include "talker.h"
+#include "strings.h"
 
 void topten(int argc, char **argv)
 {

Added: trunk/src/topten.h
===================================================================
--- trunk/src/topten.h	                        (rev 0)
+++ trunk/src/topten.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,6 @@
+#ifndef TOPTEN_H
+#define TOPTEN_H
+
+void topten(int argc, char **argv);
+
+#endif /* TOPTEN_H */

Modified: trunk/src/uri.c
===================================================================
--- trunk/src/uri.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/uri.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -8,6 +8,11 @@
 #include "user.h"
 #include "uri.h"
 #include "sqlite.h"
+#include "talker.h"
+#include "main.h"
+#include "strings.h"
+#include "mesg.h"
+#include "perms.h"
 
 extern struct person *user;
 

Modified: trunk/src/uri.h
===================================================================
--- trunk/src/uri.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/uri.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,3 +1,6 @@
+#ifndef URI_H
+#define URI_H
+
 #define URLFLAG_NSFW	0x0001
 #define URLFLAG_ANON	0x0002
 #define URLFLAG_SUCS	0x0004
@@ -38,3 +41,5 @@
 
 char *uri_action_tc(const char *text, int state);
 char *uri_arg_tc(const char *text, int state);
+
+#endif /* URI_H */

Modified: trunk/src/user.c
===================================================================
--- trunk/src/user.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/user.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -14,9 +14,16 @@
 #include "bb.h"
 #include "special.h"
 #include "talker_privs.h"
+#include "talker.h"
 #include "files.h"
 #include "strings.h"
 #include "user.h"
+#include "getpass.h"
+#include "perms.h"
+#include "mesg.h"
+#include "read.h"
+#include "who.h"
+#include "echo.h"
 
 char *partlist_search[]={
 "status", "special", "groups", "chatprivs", "chatmode", "protpower",
@@ -59,26 +66,64 @@
 	close(outfile);
 }
 
-void login_ok(struct person *usr, int32_t *userposn, int *autochat)
-{	
-	/* main function */
-	char name[NAMESIZE+1];
-	int okay;
-	do{
-		get_login(name, *autochat);
-		if(is_old(usr,name,userposn))
+int old_usr(struct person *usr)
+{
+	char salt[3],passwd[PASSWDSIZE];
+	char *name;
+
+	name=(char *)getmylogin();
+	if (name==NULL || !stringcmp(usr->name,name,-1))
+	{
+		strncpy(salt,usr->passwd,2);
+		fflush(stdin);
+		strcpy(passwd,crypt(get_pass(_("Enter Password: ")),salt));
+		if (strcmp(passwd,usr->passwd))
 		{
-			okay=old_usr(usr);
+			printf(_("Login Incorrect.\n\n"));
+			SAFE_FREE(user);
+			SAFE_FREE(fold);
+			exit(0);
 		}
-		else
-		{
-			*autochat = 0;
-			okay=new_usr(usr,name,userposn);
-		}
-	}while (!okay);
-	check_copies(*userposn); 	
+	}
+	if (u_ban(usr->status))
+	{
+		printf(_("Sorry, this username has been banned.\n"));
+		printf(_("Have a nice day. *:-)\n"));
+		SAFE_FREE(user);
+		SAFE_FREE(fold);
+		exit(0);
+	}
+#if (!defined(RELEASE) && !defined(PUBLIC))
+	if (getuid()!=geteuid() && !s_devel(usr->special) && !u_god(usr->status))
+	{
+		printf(_("Sorry, you do not have permission to run development versions of milliways.\n"));
+		SAFE_FREE(user);
+		SAFE_FREE(fold);
+		exit(0);
+	}
+#endif
+	printf(_("Hello %s.\n"),usr->name);
+	return(TRUE);
 }
 
+void strip_name(char *string)
+{
+	char *array;
+	int i,ptr=0;
+	int len;
+	
+	len=strlen(string);
+	array=(char *)malloc(len+1);
+	for (i=0;i<len;i++)
+	{
+		if (isascii(string[i]) && (isalnum(string[i]) || string[i]=='_' || string[i]=='-'))
+			array[ptr++]=string[i];
+	}
+	array[ptr]=0;
+	strcpy(string,array);
+	free(array);
+}
+
 void get_login(char *name, int autochat)
 {
 	char *lname = getmylogin();
@@ -113,24 +158,6 @@
 	}	
 }
 
-void strip_name(char *string)
-{
-	char *array;
-	int i,ptr=0;
-	int len;
-	
-	len=strlen(string);
-	array=(char *)malloc(len+1);
-	for (i=0;i<len;i++)
-	{
-		if (isascii(string[i]) && (isalnum(string[i]) || string[i]=='_' || string[i]=='-'))
-			array[ptr++]=string[i];
-	}
-	array[ptr]=0;
-	strcpy(string,array);
-	free(array);
-}
-
 int get_person(int file, struct person *tmp)
 {
 	int no;
@@ -150,119 +177,13 @@
 	return(TRUE);
 }
 
-int old_usr(struct person *usr)
+void pick_salt(char *salt)
 {
-	char salt[3],passwd[PASSWDSIZE];
-	char *name;
-
-	name=(char *)getmylogin();
-	if (name==NULL || !stringcmp(usr->name,name,-1))
-	{
-		strncpy(salt,usr->passwd,2);
-		fflush(stdin);
-		strcpy(passwd,crypt(get_pass(_("Enter Password: ")),salt));
-		if (strcmp(passwd,usr->passwd))
-		{
-			printf(_("Login Incorrect.\n\n"));
-			SAFE_FREE(user);
-			SAFE_FREE(fold);
-			exit(0);
-		}
-	}
-	if (u_ban(usr->status))
-	{
-		printf(_("Sorry, this username has been banned.\n"));
-		printf(_("Have a nice day. *:-)\n"));
-		SAFE_FREE(user);
-		SAFE_FREE(fold);
-		exit(0);
-	}
-#if (!defined(RELEASE) && !defined(PUBLIC))
-	if (getuid()!=geteuid() && !s_devel(usr->special) && !u_god(usr->status))
-	{
-		printf(_("Sorry, you do not have permission to run development versions of milliways.\n"));
-		SAFE_FREE(user);
-		SAFE_FREE(fold);
-		exit(0);
-	}
-#endif
-	printf(_("Hello %s.\n"),usr->name);
-	return(TRUE);
+	strcpy(salt,"ab");
 }
 
-int new_usr(struct person *usr, char *name, int32_t *userposn)
+static void set_defaults(struct person *tmp)
 {
-	char passwd[PASSWDSIZE],passwd2[PASSWDSIZE],salt[3];
-	char c[10];
-	do{
-		printf(_("Did I get your name right %s ? y/n: "),name);
-		get_str(c,9);
-	}while (!*c);
-	if(*c=='y' || *c=='Y')
-	{
-		int diff=FALSE;
-#ifndef RELEASE
-		if (getuid()!=geteuid())
-		{
-			printf(_("Sorry, you do not have permission to run development versions of milliways.\nPlease log in again using the public version.\n"));
-			SAFE_FREE(user);
-			SAFE_FREE(fold);
-			exit(0);
-		}
-#endif
-		pick_salt(salt);
-		printf(_("We use a password on this BB.\n"));
-		fflush(stdout);
-		do{
-			if (diff) printf(_("Passwords did not match.\n"));
-			strcpy(passwd,crypt(get_pass(_("Enter password: ")),salt));
-			strcpy(passwd2,crypt(get_pass(_("Re-enter password: ")),salt));
-		}while ((diff=strcmp(passwd,passwd2)));
-		strncpy(usr->passwd,passwd,PASSWDSIZE);
-		strncpy(usr->name,name,NAMESIZE);
-
-		printf(_("\nPlease enter the following details so that we can register you as a\n"));
-		printf(_("normal user of this bulletin board. without correct information you\n"));
-		printf(_("will not be allowed to use the full facilities of this board.\n"));
-		printf(_("\nDATA PROTECTION ACT:\n"));
-		printf(_("Any data entered will be recorded in a computer database for the purpose\n"));
-		printf(_("of the administration, operation and security of the computer society. By \n"));
-		printf(_("entering this data you consent to the storage of this data, and become an\n"));
-		printf(_("associate member of the society.\n"));
-		printf(_("\nIf you do not wish to register, do not enter a name.\n\n"));
-
-
-		printf(_("Real Name: "));
-		usr->realname[0]=0;
-		get_str(usr->realname,REALNAMESIZE);
-		if (!usr->realname[0])
-		{
-			printf(_("User record '%s' cancelled.\n"),usr->name);
-			printf(_("Goodbye.\n"));
-			SAFE_FREE(user);
-			SAFE_FREE(fold);
-			exit(0);
-		}
-		strip_str(usr->realname);
-		printf(_("Email address: "));
-		usr->contact[0]=0;
-		get_str(usr->contact,CONTACTSIZE);
-		strip_str(usr->contact);
-
-		mwlog("CREATED: %s <%s>",usr->realname, usr->contact);
-		broadcast(3, "Created user %s: %s <%s>", name, usr->realname, usr->contact);
-		set_defaults(usr);
-		user=usr;
-		printf(_("Creating new user %s\n"),name);
-
-		write_usr(usr,userposn);
-		return(TRUE);
-	}
-	else return(FALSE);	
-}
-
-void set_defaults(struct person *tmp)
-{
 	int		i, n;
 	struct folder	f;
 	int		index;
@@ -351,11 +272,97 @@
 	}
 }
 
-void pick_salt(char *salt)
+int new_usr(struct person *usr, char *name, int32_t *userposn)
 {
-	strcpy(salt,"ab");
+	char passwd[PASSWDSIZE],passwd2[PASSWDSIZE],salt[3];
+	char c[10];
+	do{
+		printf(_("Did I get your name right %s ? y/n: "),name);
+		get_str(c,9);
+	}while (!*c);
+	if(*c=='y' || *c=='Y')
+	{
+		int diff=FALSE;
+#ifndef RELEASE
+		if (getuid()!=geteuid())
+		{
+			printf(_("Sorry, you do not have permission to run development versions of milliways.\nPlease log in again using the public version.\n"));
+			SAFE_FREE(user);
+			SAFE_FREE(fold);
+			exit(0);
+		}
+#endif
+		pick_salt(salt);
+		printf(_("We use a password on this BB.\n"));
+		fflush(stdout);
+		do{
+			if (diff) printf(_("Passwords did not match.\n"));
+			strcpy(passwd,crypt(get_pass(_("Enter password: ")),salt));
+			strcpy(passwd2,crypt(get_pass(_("Re-enter password: ")),salt));
+		}while ((diff=strcmp(passwd,passwd2)));
+		strncpy(usr->passwd,passwd,PASSWDSIZE);
+		strncpy(usr->name,name,NAMESIZE);
+
+		printf(_("\nPlease enter the following details so that we can register you as a\n"));
+		printf(_("normal user of this bulletin board. without correct information you\n"));
+		printf(_("will not be allowed to use the full facilities of this board.\n"));
+		printf(_("\nDATA PROTECTION ACT:\n"));
+		printf(_("Any data entered will be recorded in a computer database for the purpose\n"));
+		printf(_("of the administration, operation and security of the computer society. By \n"));
+		printf(_("entering this data you consent to the storage of this data, and become an\n"));
+		printf(_("associate member of the society.\n"));
+		printf(_("\nIf you do not wish to register, do not enter a name.\n\n"));
+
+
+		printf(_("Real Name: "));
+		usr->realname[0]=0;
+		get_str(usr->realname,REALNAMESIZE);
+		if (!usr->realname[0])
+		{
+			printf(_("User record '%s' cancelled.\n"),usr->name);
+			printf(_("Goodbye.\n"));
+			SAFE_FREE(user);
+			SAFE_FREE(fold);
+			exit(0);
+		}
+		strip_str(usr->realname);
+		printf(_("Email address: "));
+		usr->contact[0]=0;
+		get_str(usr->contact,CONTACTSIZE);
+		strip_str(usr->contact);
+
+		mwlog("CREATED: %s <%s>",usr->realname, usr->contact);
+		broadcast(3, "Created user %s: %s <%s>", name, usr->realname, usr->contact);
+		set_defaults(usr);
+		user=usr;
+		printf(_("Creating new user %s\n"),name);
+
+		write_usr(usr,userposn);
+		return(TRUE);
+	}
+	else return(FALSE);	
 }
 
+void login_ok(struct person *usr, int32_t *userposn, int *autochat)
+{	
+	/* main function */
+	char name[NAMESIZE+1];
+	int okay;
+	do{
+		get_login(name, *autochat);
+		if(is_old(usr,name,userposn))
+		{
+			okay=old_usr(usr);
+		}
+		else
+		{
+			*autochat = 0;
+			okay=new_usr(usr,name,userposn);
+		}
+	}while (!okay);
+	check_copies(*userposn); 	
+}
+
 void list_users(int newonly) 
 {
 	int file;

Modified: trunk/src/user.h
===================================================================
--- trunk/src/user.h	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/user.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -1,6 +1,19 @@
 #ifndef USER_H
 #define USER_H
 
+#include <stdint.h>
+
 struct person * user_get(const char * name);
+char *getmylogin(void);
+void get_login(char *name, int autochat);
+int get_person(int file, struct person *tmp);
+void update_user(struct person *record, int32_t userposn);
+void list_users(int newonly);
+void list_users_since(long date);
+void login_ok(struct person *usr, int32_t *userposn, int *autochat);
+void strip_name(char *string);
+void pick_salt(char *salt);
+void search(char *args, char *ptr);
+void fetch_user(struct person *record, int32_t userposn);
 
 #endif

Modified: trunk/src/who.c
===================================================================
--- trunk/src/who.c	2010-06-26 19:54:11 UTC (rev 1149)
+++ trunk/src/who.c	2010-07-12 21:29:37 UTC (rev 1150)
@@ -16,6 +16,11 @@
 #include "rooms.h"
 #include "strings.h"
 #include "ipc.h"
+#include "files.h"
+#include "locking.h"
+#include "perms.h"
+#include "who.h"
+#include "talker.h"
 
 extern int busy;
 extern struct person *user;

Added: trunk/src/who.h
===================================================================
--- trunk/src/who.h	                        (rev 0)
+++ trunk/src/who.h	2010-07-12 21:29:37 UTC (rev 1150)
@@ -0,0 +1,13 @@
+#ifndef WHO_H
+#define WHO_H
+
+#include <stdint.h>
+
+void check_copies(int32_t where);
+void who_list(int mode);
+void what_list(void);
+void who_delete(int pid);
+char *itime(unsigned long t);
+int32_t get_who_userposn(int pid);
+
+#endif /* WHO_H */




More information about the mw-devel mailing list