[mw-devel] MW3 r1155 - trunk/src

welshbyte at sucs.org welshbyte at sucs.org
Tue Jul 20 21:43:20 BST 2010


Author: welshbyte
Date: 2010-07-20 21:43:20 +0100 (Tue, 20 Jul 2010)
New Revision: 1155

Modified:
   trunk/src/files.c
   trunk/src/files.h
   trunk/src/incoming.c
   trunk/src/incoming.h
   trunk/src/mesg.c
   trunk/src/mesg.h
Log:
Move get_pipe_name(), create_pipe(), open_fifo() and close_fifo() into files.c



Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/files.c	2010-07-20 20:43:20 UTC (rev 1155)
@@ -2,7 +2,6 @@
  * Operations on the shared files of MW3: who.bb, user.bb, folders.bb
  */
 
-#include "files.h"
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -16,7 +15,42 @@
 #include "strings.h"
 #include "user.h"
 #include "perms.h"
+#include "files.h"
 
+int incoming_pipe;
+
+char *get_pipe_name(int pid)
+{
+	static char fullpath[MAXTEXTLENGTH];
+	snprintf(fullpath,MAXTEXTLENGTH-1,MSGDIR"/bbs.%d",pid);
+	return(fullpath);
+}
+
+void create_pipe(void)
+{
+	if (mkfifo(get_pipe_name(getpid()),0600))
+	{
+		perror("Error in Creating mesg pipe");
+		exit(-1);
+	}
+}
+
+void open_fifo(void)
+{
+	if ((incoming_pipe=open(get_pipe_name(getpid()),O_RDWR))<0)
+	{
+		perror("Error opening incoming pipe");
+		exit(-1);
+	}
+}
+
+void close_fifo(void)
+{
+	if(incoming_pipe)
+		close(incoming_pipe);
+	unlink(get_pipe_name(getpid()));
+}
+
 void Lock_File(int f)
 {
 	errno=0;

Modified: trunk/src/files.h
===================================================================
--- trunk/src/files.h	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/files.h	2010-07-20 20:43:20 UTC (rev 1155)
@@ -9,6 +9,10 @@
 #define USERFILE    STATEDIR"/users.bb"
 #define WHOFILE     MSGDIR"/who.bb"
 
+void create_pipe(void);
+char *get_pipe_name(int pid);
+void open_fifo(void);
+void close_fifo(void);
 void Lock_File(int f);
 void Unlock_File(int f);
 int openfolderfile(int mode);
@@ -23,4 +27,6 @@
 int get_folder_entry(int file, struct folder *tmp);
 int get_folder_number(struct folder *fol, int num);
 
+extern int incoming_pipe;
+
 #endif

Modified: trunk/src/incoming.c
===================================================================
--- trunk/src/incoming.c	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/incoming.c	2010-07-20 20:43:20 UTC (rev 1155)
@@ -4,9 +4,7 @@
  *       see licence for furthur information.            *
  *********************************************************/
 
-#include <unistd.h>
 #include <fcntl.h>
-#include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -24,6 +22,7 @@
 #include "perms.h"
 #include "who.h"
 #include "user.h"
+#include "files.h"
 #include "mesg.h"
 #include "echo.h"
 
@@ -33,14 +32,12 @@
 extern Alias onoff_list;
 extern Alias ipc_list;
 extern Alias force_list;
-//extern int script_output;
 extern struct person *user;
 extern long userposn;
 extern struct room myroom;
 extern int runautoexec;
 extern int quietmode;
 
-int incoming_pipe;
 int new_mail_waiting=0;
 int mesg_waiting = 0;
 struct IgnoreList *ignored;
@@ -987,19 +984,3 @@
 	close_down(3, from, msg);
 }
 
-void open_fifo(void)
-{
-	if ((incoming_pipe=open(get_pipe_name(getpid()),O_RDWR))<0)
-	{
-		perror("Error opening incoming pipe");
-		exit(-1);
-	}
-}
-
-void close_fifo(void)
-{
-	if(incoming_pipe)
-		close(incoming_pipe);
-	unlink(get_pipe_name(getpid()));
-}
-

Modified: trunk/src/incoming.h
===================================================================
--- trunk/src/incoming.h	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/incoming.h	2010-07-20 20:43:20 UTC (rev 1155)
@@ -24,14 +24,11 @@
 };
 
 extern int new_mail_waiting;
-extern int incoming_pipe;
 extern char *mrod_user;
 
 /* user ignore list */
 extern struct IgnoreList *ignored;
 
-void open_fifo(void);
-void close_fifo(void);
 void incoming_mesg(int ignore);
 void handle_mesg(void);
 void InsertMesg(struct mstack *mesg);

Modified: trunk/src/mesg.c
===================================================================
--- trunk/src/mesg.c	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/mesg.c	2010-07-20 20:43:20 UTC (rev 1155)
@@ -12,22 +12,6 @@
 #include "perms.h"
 #include "files.h"
 
-char *get_pipe_name(int pid)
-{
-	static char fullpath[MAXTEXTLENGTH];
-	snprintf(fullpath,MAXTEXTLENGTH-1,MSGDIR"/bbs.%d",pid);
-	return(fullpath);
-}
-
-void create_pipe(void)
-{
-	if (mkfifo(get_pipe_name(getpid()),0600))
-	{
-		perror("Error in Creating mesg pipe");
-		exit(-1);
-	}
-}
-
 void send_mesg(char *from, char *to, char *text, int wiz)
 {
 	char buff[MAXTEXTLENGTH];

Modified: trunk/src/mesg.h
===================================================================
--- trunk/src/mesg.h	2010-07-16 12:21:42 UTC (rev 1154)
+++ trunk/src/mesg.h	2010-07-20 20:43:20 UTC (rev 1155)
@@ -4,8 +4,6 @@
 #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);




More information about the mw-devel mailing list