[mw-devel] MW3 r1151 - trunk/src

welshbyte at sucs.org welshbyte at sucs.org
Wed Jul 14 23:53:37 BST 2010


Author: welshbyte
Date: 2010-07-14 23:53:37 +0100 (Wed, 14 Jul 2010)
New Revision: 1151

Removed:
   trunk/src/locking.c
   trunk/src/locking.h
Modified:
   trunk/src/Makefile
   trunk/src/Parse.c
   trunk/src/add.c
   trunk/src/bb.h
   trunk/src/colour.c
   trunk/src/edit.c
   trunk/src/edit.h
   trunk/src/files.c
   trunk/src/files.h
   trunk/src/folders.c
   trunk/src/init.c
   trunk/src/ipc.h
   trunk/src/mod.c
   trunk/src/perms.h
   trunk/src/script.c
   trunk/src/sort.h
   trunk/src/talker_privs.c
   trunk/src/tidyup.c
   trunk/src/user.c
   trunk/src/user.h
   trunk/src/who.c
Log:
Some more dependency-related rejigging:
- move the struct person definition (and associated constants) out of bb.h and into user.h
- remove locking.{c,h} and put the two locking functions into files.{c,h} (everything that included locking.h also included files.h before anyway)
- update #includes in other files to reflect the above



Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/Makefile	2010-07-14 22:53:37 UTC (rev 1151)
@@ -54,7 +54,7 @@
 .PHONY: build install clean test
 
 mw: user.o main.o read.o add.o folders.o new.o perms.o edit.o mod.o who.o\
-locking.o echo.o getpass.o filter.o mesg.o strings.o special.o Parse.o\
+echo.o getpass.o filter.o mesg.o strings.o special.o Parse.o\
 newmain.o init.o talker.o talker_privs.o colour.o bork.o rooms.o alarm.o\
 topten.o sort.o tidyup.o gags.o script_inst.o script.o\
 incoming.o command.o chattable.o alias.o frl.o hash.o vars.o expand.o\

Modified: trunk/src/Parse.c
===================================================================
--- trunk/src/Parse.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/Parse.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -7,6 +7,7 @@
 #include "init.h"
 #include "talker.h"
 #include "strings.h"
+#include "user.h"
 
 #include "Parse.h"
 #include "talker_privs.h"

Modified: trunk/src/add.c
===================================================================
--- trunk/src/add.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/add.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -21,7 +21,6 @@
 #include "main.h"
 #include "filter.h"
 #include "init.h"
-#include "locking.h"
 #include "mesg.h"
 extern int eof_caught;
 extern int remote;

Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/bb.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -56,15 +56,10 @@
 
 #define TIMEOUT		600	/* seconds */
 
-#define NAMESIZE 	16	/* username */
-#define PASSWDSIZE 	20	/* password (after encryption) */
 #define SUBJECTSIZE 	40	/* Subject field on messages */
 #define FOLNAMESIZE 	10	/* length of folder names */
 #define TOPICSIZE 	30	/* length of the topic of the folder */
-#define REALNAMESIZE	30	/* real name */
-#define CONTACTSIZE 	60	/* contact address */
 #define LOGLINESIZE	2048	/* size of a line printed to log file */
-#define DOINGSIZE	79	/* 'doing' user record field */
 #define MAXTEXTLENGTH	2048	/* text buffer size */
 #define MAXPIPELENGTH	4096	/* maximum length of a pipe message */
 
@@ -99,6 +94,8 @@
 	char ident[40]; 
 };
 
+#include "user.h"
+
 struct Header
 {
 	int32_t Ref;
@@ -124,43 +121,6 @@
 7	-
 */
 
-struct person 
-{
-	char name[NAMESIZE+1];
-	char passwd[PASSWDSIZE+1];
-	int32_t lastlogout; 
-	int32_t folders[2]; /* which folders are subscribed to */
-	unsigned char status;
-	uint16_t special;
-	int32_t lastread[64]; /* last message read in each folder */
-	char realname[REALNAMESIZE+1];
-	char contact[CONTACTSIZE+1];
-	int32_t timeused;
-	int32_t idletime;
-	char groups;
-	char doing[DOINGSIZE];
-	int32_t dowhen; /* unix time of last doing update */
-	int32_t timeout;
-
-	unsigned char spare;
-	unsigned char colour;
-	uint16_t room;
-	uint32_t chatprivs;
-	uint32_t chatmode;
-};
-
-/* person.status
-bit	use
-0	registered
-1	is a moderator
-2	is a superuser
-3	is banned
-4	messages on/off(1=off)
-5	inform on/off(1=off)
-6	-
-7	marked for deletion
-*/
-
 struct folder
 {
 	unsigned char status; /* status for people not in the same group */

Modified: trunk/src/colour.c
===================================================================
--- trunk/src/colour.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/colour.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include "bb.h"
 #include "frl.h"
+#include "user.h"
 #define COLOUR_LIMIT 40
 
 static  char *colour_chart[COLOUR_LIMIT];

Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/edit.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -26,7 +26,6 @@
 #include "getpass.h"
 #include "who.h"
 #include "edit.h"
-#include "locking.h"
 #include "init.h"
 #include "read.h"
 

Modified: trunk/src/edit.h
===================================================================
--- trunk/src/edit.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/edit.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -2,6 +2,7 @@
 #define EDIT_H
 
 #include "bb.h"
+#include "user.h"
 
 void time_on(long u);
 void edit_user(char *args, char *name);

Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/files.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -10,13 +10,30 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/file.h>
 #include <string.h>
 #include <errno.h>
 #include "strings.h"
 #include "user.h"
 #include "perms.h"
-#include "locking.h"
 
+void Lock_File(int f)
+{
+	errno=0;
+	do{
+		if (flock(f,LOCK_EX))
+			perror("Locking");
+	}while (errno==EINTR);
+}
+
+void Unlock_File(int f)
+{
+	if (flock(f,LOCK_UN))
+	{
+		perror("Unlocking");
+	}
+}
+
 static int createuserfile()
 {
 	int fd;

Modified: trunk/src/files.h
===================================================================
--- trunk/src/files.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/files.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -1,13 +1,16 @@
 #ifndef FILES_H
 #define FILES_H
 
-/* For structs person, who, folder (which may eventually move to this file) */
+#include <stdint.h>
 #include "bb.h"
+#include "user.h"
 
 #define FOLDERFILE  STATEDIR"/folders.bb"
 #define USERFILE    STATEDIR"/users.bb"
 #define WHOFILE     MSGDIR"/who.bb"
 
+void Lock_File(int f);
+void Unlock_File(int f);
 int openfolderfile(int mode);
 int nofolders(void);
 int openuserfile(int flags);

Modified: trunk/src/folders.c
===================================================================
--- trunk/src/folders.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/folders.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -15,7 +15,6 @@
 #include "strings.h"
 #include "perms.h"
 #include "folders.h"
-#include "locking.h"
 #include "user.h"
 
 void add_folder(void)

Modified: trunk/src/init.c
===================================================================
--- trunk/src/init.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/init.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -28,6 +28,7 @@
 
 #include "script.h"
 #include "frl.h"
+#include "user.h"
 
 extern struct person *user;
 

Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/ipc.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -2,6 +2,7 @@
 #define IPC_H
 
 #include "bb.h"
+#include "user.h"
 
 enum ipc_types {
 	IPC_NOOP	= 0,	// Just go through the motions, don't actually write anything to the FIFO

Deleted: trunk/src/locking.c
===================================================================
--- trunk/src/locking.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/locking.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -1,25 +0,0 @@
-/*********************************************************
- *     The Milliways III System is copyright 1992        *
- *      J.S.Mitchell. (arthur at sugalaxy.swan.ac.uk)       *
- *       see licence for furthur information.            *
- *********************************************************/
-
-#include <sys/errno.h>
-#include <sys/file.h>
-#include <stdio.h>
-void Lock_File(int f)
-{
-	errno=0;
-	do{
-		if (flock(f,LOCK_EX))
-			perror("Locking");
-	}while (errno==EINTR);
-}
-
-void Unlock_File(int f)
-{
-	if (flock(f,LOCK_UN))
-	{
-		perror("Unlocking");
-	}
-}

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

Modified: trunk/src/mod.c
===================================================================
--- trunk/src/mod.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/mod.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -10,7 +10,6 @@
 #include "files.h"
 #include "strings.h"
 #include "read.h"
-#include "locking.h"
 
 static void add_message(struct folder *fold, struct Header *head, char *text)
 {

Modified: trunk/src/perms.h
===================================================================
--- trunk/src/perms.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/perms.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -2,6 +2,7 @@
 #define PERMS_H
 
 #include "bb.h"
+#include "user.h"
 
 int u_god(int user);
 int u_mod(int user);

Modified: trunk/src/script.c
===================================================================
--- trunk/src/script.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/script.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -19,6 +19,7 @@
 #include "expand.h"
 #include "talker.h"
 #include "init.h"
+#include "user.h"
 
 #include "alias.h"
 #include "script_inst.h"

Modified: trunk/src/sort.h
===================================================================
--- trunk/src/sort.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/sort.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -1,7 +1,7 @@
 #ifndef SORT_H
 #define SORT_H
 
-#include "bb.h"
+#include "user.h"
 
 struct listing
 {

Modified: trunk/src/talker_privs.c
===================================================================
--- trunk/src/talker_privs.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/talker_privs.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -6,6 +6,7 @@
 #include "bb.h"
 #include "gags.h"
 #include "main.h"
+#include "user.h"
 
 #define FALSE 0
 #define TRUE !FALSE

Modified: trunk/src/tidyup.c
===================================================================
--- trunk/src/tidyup.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/tidyup.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -8,7 +8,6 @@
 #include "bb.h"
 #include "strings.h"
 #include "files.h"
-#include "locking.h"
 
 #define NEW_END	".t"
 

Modified: trunk/src/user.c
===================================================================
--- trunk/src/user.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/user.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <pwd.h>
-#include "bb.h"
 #include "special.h"
 #include "talker_privs.h"
 #include "talker.h"

Modified: trunk/src/user.h
===================================================================
--- trunk/src/user.h	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/user.h	2010-07-14 22:53:37 UTC (rev 1151)
@@ -3,6 +3,49 @@
 
 #include <stdint.h>
 
+#define NAMESIZE 	16	/* username */
+#define PASSWDSIZE 	20	/* password (after encryption) */
+#define REALNAMESIZE	30	/* real name */
+#define CONTACTSIZE 	60	/* contact address */
+#define DOINGSIZE	79	/* 'doing' user record field */
+
+struct person 
+{
+	char name[NAMESIZE+1];
+	char passwd[PASSWDSIZE+1];
+	int32_t lastlogout; 
+	int32_t folders[2]; /* which folders are subscribed to */
+
+	/* person.status
+	bit	use
+	0	registered
+	1	is a moderator
+	2	is a superuser
+	3	is banned
+	4	messages on/off(1=off)
+	5	inform on/off(1=off)
+	6	-
+	7	marked for deletion
+	*/
+	unsigned char status;
+	uint16_t special;
+	int32_t lastread[64]; /* last message read in each folder */
+	char realname[REALNAMESIZE+1];
+	char contact[CONTACTSIZE+1];
+	int32_t timeused;
+	int32_t idletime;
+	char groups;
+	char doing[DOINGSIZE];
+	int32_t dowhen; /* unix time of last doing update */
+	int32_t timeout;
+
+	unsigned char spare;
+	unsigned char colour;
+	uint16_t room;
+	uint32_t chatprivs;
+	uint32_t chatmode;
+};
+
 struct person * user_get(const char * name);
 char *getmylogin(void);
 void get_login(char *name, int autochat);

Modified: trunk/src/who.c
===================================================================
--- trunk/src/who.c	2010-07-12 21:29:37 UTC (rev 1150)
+++ trunk/src/who.c	2010-07-14 22:53:37 UTC (rev 1151)
@@ -17,7 +17,6 @@
 #include "strings.h"
 #include "ipc.h"
 #include "files.h"
-#include "locking.h"
 #include "perms.h"
 #include "who.h"
 #include "talker.h"




More information about the mw-devel mailing list