[mw-devel] MW3 r1156 - trunk/src
welshbyte at sucs.org
welshbyte at sucs.org
Fri Jul 23 01:02:47 BST 2010
Author: welshbyte
Date: 2010-07-23 01:02:46 +0100 (Fri, 23 Jul 2010)
New Revision: 1156
Added:
trunk/src/bool.h
trunk/src/intl.h
trunk/src/util.h
Modified:
trunk/src/add.c
trunk/src/add.h
trunk/src/alias.c
trunk/src/bb.h
trunk/src/colour.c
trunk/src/completion.c
trunk/src/edit.c
trunk/src/edit.h
trunk/src/files.c
trunk/src/files.h
trunk/src/filter.c
trunk/src/folders.c
trunk/src/folders.h
trunk/src/gags.c
trunk/src/incoming.c
trunk/src/init.c
trunk/src/ipc.c
trunk/src/ipc.h
trunk/src/js.c
trunk/src/log.c
trunk/src/main.c
trunk/src/mesg.c
trunk/src/mesg.h
trunk/src/mod.c
trunk/src/new.c
trunk/src/new.h
trunk/src/newmain.c
trunk/src/perms.c
trunk/src/perms.h
trunk/src/read.c
trunk/src/read.h
trunk/src/rooms.c
trunk/src/script.c
trunk/src/special.c
trunk/src/strings.c
trunk/src/talker.c
trunk/src/tidyup.c
trunk/src/topten.c
trunk/src/user.c
trunk/src/who.c
trunk/src/who.h
Log:
Some more reorganising to disentangle things from bb.h:
- Move struct folder into folders.h
- Move struct who into who.h
- Move TRUE and FALSE defines into bool.h (suggestion: <stdbool.h> could obsolete this)
- Move the i18n stuff into intl.h
- Move SAFE_FREE into util.h and add TR's auto cleanup buffer type stuff too
- Rejig #includes where necessary
Modified: trunk/src/add.c
===================================================================
--- trunk/src/add.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/add.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -11,6 +11,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <time.h>
#include "files.h"
#include "bb.h"
#include "alarm.h"
@@ -22,6 +23,8 @@
#include "filter.h"
#include "init.h"
#include "mesg.h"
+#include "intl.h"
+
extern int eof_caught;
extern int remote;
extern int busy;
Modified: trunk/src/add.h
===================================================================
--- trunk/src/add.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/add.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,7 +1,7 @@
#ifndef ADD_H
#define ADD_H
-#include "bb.h"
+#include "user.h"
int add_msg(int folnum,struct person *user,int replyto);
Modified: trunk/src/alias.c
===================================================================
--- trunk/src/alias.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/alias.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -5,10 +5,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "bb.h"
#include "talker.h"
#include "strings.h"
#include "main.h"
+#include "intl.h"
#include "alias.h"
Alias alias_list=NULL;
Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/bb.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -46,8 +46,6 @@
#define MOD_END ".m"
#define PATHSIZE 256
#define ERRORMSG "I don't understand. Type 'help' for help.\n"
-#define FALSE 0
-#define TRUE !FALSE
#define SETALLLONG 0xFFFFFFFF
#define CMD_BOARD_STR "!"
@@ -57,8 +55,6 @@
#define TIMEOUT 600 /* seconds */
#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 LOGLINESIZE 2048 /* size of a line printed to log file */
#define MAXTEXTLENGTH 2048 /* text buffer size */
#define MAXPIPELENGTH 4096 /* maximum length of a pipe message */
@@ -67,9 +63,6 @@
#define MAXRUNAWAY 5000
#define FLOODLIMIT 15
-
-#define SAFE_FREE(a) do { if (a) { free(a); (a) = NULL; } } while(0);
-
#define RIGHTS_BBS 0
#define RIGHTS_TALK 1
@@ -121,36 +114,6 @@
7 -
*/
-struct folder
-{
- unsigned char status; /* status for people not in the same group */
- char name[FOLNAMESIZE+1];
- char topic[TOPICSIZE+1];
- int32_t first; /* Ref no of first message in the folder */
- int32_t last; /* Ref no of last message in the folder */
- char g_status; /* status for people in the same group */
- char groups; /* which groups g_status applies to */
- char spare[10];
-};
-
-/* folder.status
-bit use
-0 active
-1 read by unregistered
-2 wrte by unregistered
-3 read by registered
-4 wrte by registered
-5 private folder
-6 moderated folder
-7 -
-*/
-
-struct who
-{
- int32_t pid;
- int32_t posn;
-};
-
typedef struct gag_info
{
char *name; /* gag filter name */
@@ -163,15 +126,7 @@
extern int internet;
-#include <unistd.h>
-#include <stdlib.h>
-#include <time.h>
-#include <libintl.h>
-#define _(String) gettext (String)
-#define N_(String) gettext_noop (String)
-
#define PACKAGE "mw"
#define LOCALEDIR HOMEPATH"/locale"
-
#endif /* BB_H */
Added: trunk/src/bool.h
===================================================================
--- trunk/src/bool.h (rev 0)
+++ trunk/src/bool.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -0,0 +1,7 @@
+#ifndef BOOL_H
+#define BOOL_H
+
+#define FALSE 0
+#define TRUE !FALSE
+
+#endif /* BOOL_H */
Modified: trunk/src/colour.c
===================================================================
--- trunk/src/colour.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/colour.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -5,6 +5,8 @@
free all the memory anyway.
**********************************************************************************/
+#include <unistd.h>
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
Modified: trunk/src/completion.c
===================================================================
--- trunk/src/completion.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/completion.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,5 +1,5 @@
+#include <unistd.h>
#include "completion.h"
-#include "bb.h"
#include "script.h"
#include "uri.h"
#include "main.h"
Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/edit.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -12,7 +12,9 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <stdarg.h>
-#include "bb.h"
+#include <stdlib.h>
+#include <time.h>
+#include "bool.h"
#include "talker_privs.h"
#include "special.h"
#include "rooms.h"
@@ -28,6 +30,7 @@
#include "edit.h"
#include "init.h"
#include "read.h"
+#include "intl.h"
char *partlist_user[]={
"edit", "status", "special", "groups", "passwd", "chatprivs", "chatmode",
Modified: trunk/src/edit.h
===================================================================
--- trunk/src/edit.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/edit.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,7 +1,6 @@
#ifndef EDIT_H
#define EDIT_H
-#include "bb.h"
#include "user.h"
void time_on(long u);
Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/files.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -16,6 +16,10 @@
#include "user.h"
#include "perms.h"
#include "files.h"
+#include "util.h"
+#include "who.h"
+#include "bool.h"
+#include "bb.h" // Just for MAXTEXTLENGTH, sigh
int incoming_pipe;
Modified: trunk/src/files.h
===================================================================
--- trunk/src/files.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/files.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -2,7 +2,7 @@
#define FILES_H
#include <stdint.h>
-#include "bb.h"
+#include "folders.h"
#include "user.h"
#define FOLDERFILE STATEDIR"/folders.bb"
Modified: trunk/src/filter.c
===================================================================
--- trunk/src/filter.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/filter.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -5,7 +5,6 @@
*********************************************************/
#include <stdio.h>
-#include "bb.h"
#include "talker.h"
void tidy_string(char *buff)
Modified: trunk/src/folders.c
===================================================================
--- trunk/src/folders.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/folders.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -9,13 +9,16 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include "bb.h"
+#include <stdlib.h>
+#include <unistd.h>
#include "ipc.h"
#include "files.h"
#include "strings.h"
#include "perms.h"
#include "folders.h"
#include "user.h"
+#include "bool.h"
+#include "intl.h"
void add_folder(void)
{
Modified: trunk/src/folders.h
===================================================================
--- trunk/src/folders.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/folders.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,6 +1,35 @@
#ifndef FOLDERS_H
#define FOLDERS_H
+#include <stdint.h>
+
+#define FOLNAMESIZE 10 /* length of folder names */
+#define TOPICSIZE 30 /* length of the topic of the folder */
+
+struct folder
+{
+ unsigned char status; /* status for people not in the same group */
+ char name[FOLNAMESIZE+1];
+ char topic[TOPICSIZE+1];
+ int32_t first; /* Ref no of first message in the folder */
+ int32_t last; /* Ref no of last message in the folder */
+ char g_status; /* status for people in the same group */
+ char groups; /* which groups g_status applies to */
+ char spare[10];
+};
+
+/* folder.status
+bit use
+0 active
+1 read by unregistered
+2 wrte by unregistered
+3 read by registered
+4 wrte by registered
+5 private folder
+6 moderated folder
+7 -
+*/
+
void auto_subscribe(int folnum, int state);
void add_folder(void);
Modified: trunk/src/gags.c
===================================================================
--- trunk/src/gags.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/gags.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
Modified: trunk/src/incoming.c
===================================================================
--- trunk/src/incoming.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/incoming.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -7,8 +7,10 @@
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
-#include "bb.h"
#include "incoming.h"
#include "main.h"
#include "talker_privs.h"
@@ -25,6 +27,7 @@
#include "files.h"
#include "mesg.h"
#include "echo.h"
+#include "intl.h"
extern int script_terminate;
extern Alias rpc_list;
Modified: trunk/src/init.c
===================================================================
--- trunk/src/init.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/init.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -12,6 +12,7 @@
#include <errno.h>
#include <unistd.h>
#include "bb.h"
+#include "intl.h"
#include "alias.h"
#include "js.h"
#include "sqlite.h"
Added: trunk/src/intl.h
===================================================================
--- trunk/src/intl.h (rev 0)
+++ trunk/src/intl.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -0,0 +1,8 @@
+#ifndef INTL_H
+#define INTL_H
+
+#include <libintl.h>
+#define _(String) gettext (String)
+#define N_(String) gettext_noop (String)
+
+#endif /* INTL_H */
Modified: trunk/src/ipc.c
===================================================================
--- trunk/src/ipc.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/ipc.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,4 +1,5 @@
-
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/ipc.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,7 +1,8 @@
#ifndef IPC_H
#define IPC_H
-#include "bb.h"
+#include <unistd.h>
+#include "who.h"
#include "user.h"
enum ipc_types {
Modified: trunk/src/js.c
===================================================================
--- trunk/src/js.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/js.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -29,6 +29,7 @@
#include "files.h"
#include "user.h"
#include "init.h"
+#include "who.h"
extern Alias alias_list;
extern Alias bind_list;
Modified: trunk/src/log.c
===================================================================
--- trunk/src/log.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/log.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/main.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -54,6 +54,8 @@
#include "add.h"
#include "colour.h"
#include "init.h"
+#include "bool.h"
+#include "intl.h"
#include <pwd.h>
#include <grp.h>
Modified: trunk/src/mesg.c
===================================================================
--- trunk/src/mesg.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/mesg.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,3 +1,5 @@
+#include <unistd.h>
+#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -11,6 +13,7 @@
#include "user.h"
#include "perms.h"
#include "files.h"
+#include "intl.h"
void send_mesg(char *from, char *to, char *text, int wiz)
{
Modified: trunk/src/mesg.h
===================================================================
--- trunk/src/mesg.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/mesg.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,6 +1,8 @@
#ifndef MESG_H
#define MESG_H
+#include "user.h"
+#include "folders.h"
#include "bb.h"
void broadcast(int state, char *fmt, ...);
Modified: trunk/src/mod.c
===================================================================
--- trunk/src/mod.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/mod.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -3,13 +3,16 @@
* J.S.Mitchell. (arthur at sugalaxy.swan.ac.uk) *
* see licence for furthur information. *
*********************************************************/
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
-#include "bb.h"
#include "files.h"
#include "strings.h"
#include "read.h"
+#include "intl.h"
static void add_message(struct folder *fold, struct Header *head, char *text)
{
Modified: trunk/src/new.c
===================================================================
--- trunk/src/new.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/new.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -8,7 +8,7 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include "bb.h"
+#include "bool.h"
#include "alarm.h"
#include "incoming.h"
#include "strings.h"
@@ -18,6 +18,7 @@
#include "read.h"
#include "main.h"
#include "add.h"
+#include "intl.h"
extern int remote;
extern int busy;
Modified: trunk/src/new.h
===================================================================
--- trunk/src/new.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/new.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,7 +1,7 @@
#ifndef NEW_H
#define NEW_H
-#include "bb.h"
+#include "user.h"
void list_new_items(struct person *user, int flag);
void new(struct person *user);
Modified: trunk/src/newmain.c
===================================================================
--- trunk/src/newmain.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/newmain.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
@@ -9,8 +10,8 @@
#include <errno.h>
#include <unistd.h>
#include <string.h>
-#include <locale.h>
-#include "bb.h"
+#include <time.h>
+#include "bool.h"
#include "Parse.h"
#include "iconv.h"
#include "strings.h"
@@ -37,6 +38,7 @@
#include "special.h"
#include "ipc.h"
#include "log.h"
+#include "intl.h"
#include "alias.h"
extern Alias alias_list;
Modified: trunk/src/perms.c
===================================================================
--- trunk/src/perms.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/perms.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -8,8 +8,10 @@
#include <time.h>
#include <string.h>
#include <stdarg.h>
+#include <unistd.h>
#include "bb.h"
+#include "bool.h"
#include "perms.h"
int allowed_r(struct folder *fol, struct person *usr)
Modified: trunk/src/perms.h
===================================================================
--- trunk/src/perms.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/perms.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,7 +1,7 @@
#ifndef PERMS_H
#define PERMS_H
-#include "bb.h"
+#include "folders.h"
#include "user.h"
int u_god(int user);
Modified: trunk/src/read.c
===================================================================
--- trunk/src/read.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/read.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -4,17 +4,19 @@
* see licence for furthur information. *
*********************************************************/
+#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
-#include "bb.h"
+#include "bool.h"
#include "strings.h"
#include "perms.h"
#include "read.h"
#include "files.h"
#include "talker.h"
#include "echo.h"
+#include "util.h"
extern int remote;
extern FILE *output;
@@ -175,7 +177,7 @@
int afile;
struct folder fold;
struct Header head;
- char *tmp;
+ AUTOFREE_BUFFER tmp;
char buff[SUBJECTSIZE+1];
int linecount=0;
int listpoint;
@@ -191,10 +193,8 @@
if ((afile=open(tmp,O_RDONLY))<0)
{
printf("There are no messages in folder %s\n",fold.name);
- free(tmp);
return;
}
- free(tmp);
if (many>0)
{
listpoint=fold.first+many;
Modified: trunk/src/read.h
===================================================================
--- trunk/src/read.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/read.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,6 +1,8 @@
#ifndef READ_H
#define READ_H
+#include "user.h"
+#include "folders.h"
#include "bb.h"
int get_mesg_header(struct folder *data, int msgnum, struct Header *head);
Modified: trunk/src/rooms.c
===================================================================
--- trunk/src/rooms.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/rooms.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -18,6 +18,7 @@
#include "user.h"
#include "main.h"
#include "rooms.h"
+#include "util.h"
extern unsigned long rights;
#define MAX_ARGC 128
@@ -84,13 +85,14 @@
* 2 - frozen
* 3 - invalid direction/room
* 4 - invalid number
+ * 5 - OOM
*/
int ChangeRoom(char *room, int quiet)
{
struct room tmp;
int i;
unsigned short oldroom = user->room;
- char buff[MAXTEXTLENGTH];
+ AUTOFREE_BUFFER buff;
if (cm_flags(user->chatmode,CM_FROZEN,CM_MODE_ANY))
{
@@ -132,7 +134,10 @@
}
else
{
- snprintf(buff,MAXTEXTLENGTH-1,"\03312%s has just arrived in room %d", user->name, i);
+ if (asprintf(&buff, "\03312%s has just arrived in room %d", user->name, i) < 0)
+ {
+ return 5;
+ }
if (!quiet) talk_send_raw(buff, i);
user->room = i;
update_user(user, userposn);
@@ -141,9 +146,15 @@
RoomInit(&myroom);
LoadRoom(&myroom, user->room);
- snprintf(buff,MAXTEXTLENGTH-1,"\03313%s has left to room %d", user->name, i);
+ if (asprintf(&buff, "\03313%s has left to room %d", user->name, i) > 0)
+ {
+ return 5;
+ }
if (!quiet) talk_send_raw(buff, oldroom);
- snprintf(buff,MAXTEXTLENGTH-1,"Leaving room %d for room %d",oldroom,user->room);
+ if (asprintf(&buff, "Leaving room %d for room %d", oldroom, user->room) < 0)
+ {
+ return 5;
+ }
if (!quiet) display_message(buff, 1, 1);
}
}
Modified: trunk/src/script.c
===================================================================
--- trunk/src/script.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/script.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -20,7 +20,7 @@
#include "talker.h"
#include "init.h"
#include "user.h"
-
+#include "bool.h"
#include "alias.h"
#include "script_inst.h"
#include "scrcomplete.h"
Modified: trunk/src/special.c
===================================================================
--- trunk/src/special.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/special.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -7,7 +7,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
-#include "bb.h"
+#include "bool.h"
/* short = 16 bits */
unsigned short set_special(char *string, unsigned short stat)
Modified: trunk/src/strings.c
===================================================================
--- trunk/src/strings.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/strings.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
Modified: trunk/src/talker.c
===================================================================
--- trunk/src/talker.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/talker.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -1,3 +1,4 @@
+#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
@@ -28,12 +29,14 @@
#include "main.h"
#include "init.h"
#include "echo.h"
-
+#include "bool.h"
#include "rooms.h"
#include "ipc.h"
#include "log.h"
#include "user.h"
#include "uri.h"
+#include "util.h"
+#include "intl.h"
#include "alias.h"
extern Alias bind_list;
Modified: trunk/src/tidyup.c
===================================================================
--- trunk/src/tidyup.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/tidyup.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -3,6 +3,8 @@
* J.S.Mitchell. (arthur at sugalaxy.swan.ac.uk) *
* see licence for furthur information. *
*********************************************************/
+#include <unistd.h>
+#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "bb.h"
Modified: trunk/src/topten.c
===================================================================
--- trunk/src/topten.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/topten.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -7,6 +7,7 @@
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include "bb.h"
#include "sort.h"
#include "talker.h"
Modified: trunk/src/user.c
===================================================================
--- trunk/src/user.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/user.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
+#include <time.h>
#include "special.h"
#include "talker_privs.h"
#include "talker.h"
@@ -23,6 +24,9 @@
#include "read.h"
#include "who.h"
#include "echo.h"
+#include "bool.h"
+#include "util.h"
+#include "intl.h"
char *partlist_search[]={
"status", "special", "groups", "chatprivs", "chatmode", "protpower",
Added: trunk/src/util.h
===================================================================
--- trunk/src/util.h (rev 0)
+++ trunk/src/util.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -0,0 +1,21 @@
+#ifndef UTIL_H
+#define UTIL_H
+
+#include <stdlib.h>
+
+/* TR's auto-free asprintf type stuff */
+__attribute__((unused)) static inline void cleanup_buffer(void *buffer)
+{
+ char **b = buffer;
+ if (NULL != *b)
+ {
+ free(*b);
+ }
+}
+#define AUTOFREE_BUFFER __attribute__((cleanup(cleanup_buffer))) char *
+
+
+#define SAFE_FREE(a) do { if (a) { free(a); (a) = NULL; } } while(0);
+
+
+#endif /* UTIL_H */
Modified: trunk/src/who.c
===================================================================
--- trunk/src/who.c 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/who.c 2010-07-23 00:02:46 UTC (rev 1156)
@@ -4,12 +4,14 @@
* see licence for furthur information. *
*********************************************************/
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
-#include "bb.h"
#include <fcntl.h>
+#include <time.h>
#include "talker_privs.h"
#include "special.h"
@@ -20,6 +22,7 @@
#include "perms.h"
#include "who.h"
#include "talker.h"
+#include "bool.h"
extern int busy;
extern struct person *user;
Modified: trunk/src/who.h
===================================================================
--- trunk/src/who.h 2010-07-20 20:43:20 UTC (rev 1155)
+++ trunk/src/who.h 2010-07-23 00:02:46 UTC (rev 1156)
@@ -3,6 +3,12 @@
#include <stdint.h>
+struct who
+{
+ int32_t pid;
+ int32_t posn;
+};
+
void check_copies(int32_t where);
void who_list(int mode);
void what_list(void);
More information about the mw-devel
mailing list