[mw-devel] MW3 r1347 - in trunk/src: . client utils
welshbyte at sucs.org
welshbyte at sucs.org
Thu Oct 31 20:52:36 GMT 2013
Author: welshbyte
Date: 2013-10-31 20:52:36 +0000 (Thu, 31 Oct 2013)
New Revision: 1347
Added:
trunk/src/mesg.h
Modified:
trunk/src/client/incoming.c
trunk/src/client/mesg.c
trunk/src/client/mesg.h
trunk/src/client/uri.c
trunk/src/client/user.c
trunk/src/utils/Makefile
trunk/src/utils/del_user.c
trunk/src/utils/fixuser.c
trunk/src/utils/listuser.c
trunk/src/utils/sizes.c
Log:
Fix building src/utils/* and move the Header struct into src/mesg.h
Modified: trunk/src/client/incoming.c
===================================================================
--- trunk/src/client/incoming.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/client/incoming.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -26,6 +26,7 @@
#include "socket.h"
#include "bb.h"
#include "who.h"
+#include "user.h"
extern Alias rpc_list;
extern Alias event_list;
Modified: trunk/src/client/mesg.c
===================================================================
--- trunk/src/client/mesg.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/client/mesg.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -11,6 +11,7 @@
#include "intl.h"
#include "mesg.h"
#include "bb.h"
+#include "user.h"
void send_mesg(char *from, const char *to, char *text, int wiz)
{
Modified: trunk/src/client/mesg.h
===================================================================
--- trunk/src/client/mesg.h 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/client/mesg.h 2013-10-31 20:52:36 UTC (rev 1347)
@@ -1,36 +1,8 @@
#ifndef MESG_H
#define MESG_H
-#include <folders.h>
-#include "user.h"
+#include <mesg.h>
-#define SUBJECTSIZE 40
-
-struct Header {
- int32_t Ref;
- int32_t date;
- char from[NAMESIZE+1];
- char to[SUBJECTSIZE+1];
- char subject[SUBJECTSIZE+1];
- int32_t datafield;
- int32_t size;
- char status;
- int32_t replyto;
- char spare[4]; /*adjust size as necessary */
-};
-
-/* Header.status
-bit use
-0 moderator approved
-1 marked for deletion
-2 has a reply
-3 is a remote posting
-4 -
-5 -
-6 -
-7 -
-*/
-
void broadcast(int state, const char *fmt, ...) __attribute__((format(printf,2,3)));
void inform_of_mail(char *to);
void postinfo(struct person *who, struct folder *fol, struct Header *mesg);
Modified: trunk/src/client/uri.c
===================================================================
--- trunk/src/client/uri.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/client/uri.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -10,10 +10,11 @@
#include "talker.h"
#include "main.h"
#include "strings.h"
-#include "mesg.h"
#include "perms.h"
#include "bb.h"
#include "userio.h"
+#include "user.h"
+#include "mesg.h"
extern struct person *user;
Modified: trunk/src/client/user.c
===================================================================
--- trunk/src/client/user.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/client/user.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -25,6 +25,7 @@
#include "util.h"
#include "intl.h"
#include "userio.h"
+#include "user.h"
const char *partlist_search[]={
"status", "special", "groups", "chatprivs", "chatmode", "protpower",
Copied: trunk/src/mesg.h (from rev 1344, trunk/src/client/mesg.h)
===================================================================
--- trunk/src/mesg.h (rev 0)
+++ trunk/src/mesg.h 2013-10-31 20:52:36 UTC (rev 1347)
@@ -0,0 +1,33 @@
+#ifndef MW_MESG_H
+#define MW_MESG_H
+
+#include <user.h>
+
+#define SUBJECTSIZE 40
+
+struct Header {
+ int32_t Ref;
+ int32_t date;
+ char from[NAMESIZE+1];
+ char to[SUBJECTSIZE+1];
+ char subject[SUBJECTSIZE+1];
+ int32_t datafield;
+ int32_t size;
+ char status;
+ int32_t replyto;
+ char spare[4]; /*adjust size as necessary */
+};
+
+/* Header.status
+bit use
+0 moderator approved
+1 marked for deletion
+2 has a reply
+3 is a remote posting
+4 -
+5 -
+6 -
+7 -
+*/
+
+#endif /* MW_MESG_H */
Modified: trunk/src/utils/Makefile
===================================================================
--- trunk/src/utils/Makefile 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/utils/Makefile 2013-10-31 20:52:36 UTC (rev 1347)
@@ -1,11 +1,23 @@
-CFLAGS=
+SRCROOT = $(CURDIR)/../..
+DEPTH=../../
+include ../../Makefile.common
+LDFLAGS+= -L..
+CFLAGS+= -I..
+
all: listuser fixuser del_user sizes
-listuser: listuser.c ../bb.h
- $(CC) $(CFLAGS) listuser.c -o listuser
+listuser: listuser.o
+ $(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
-fixuser: fixuser.c ../bb.h
- $(CC) $(CFLAGS) fixuser.c -o fixuser
+fixuser: fixuser.o
+ $(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
-del_user: del_user.c ../libmw.a ../client/userio.o
+del_user: del_user.o ../libmw.a
+ $(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
+
+sizes: sizes.o
+ $(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
+
+clean:
+ rm -f *.o *.d listuser fixuser del_user sizes
Modified: trunk/src/utils/del_user.c
===================================================================
--- trunk/src/utils/del_user.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/utils/del_user.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -1,29 +1,31 @@
#include <stdio.h>
+#include <stdlib.h>
#include <fcntl.h>
-#include "bb.h"
-#include "files.h"
+#include <unistd.h>
+#include <time.h>
+#include <bb.h>
+#include <files.h>
+#include <perms.h>
+
int internet=0;
struct person user;
-main()
+int main(void)
{
- char newpath[1024];
+ const char *newpath = USERFILE ".new";
int newfile,oldfile;
- char buff[20];
long tt=0l;
- sprintf(newpath,"%s.new",USERFILE);
-
if ((oldfile=open(USERFILE,O_RDONLY))<0)
{
perror(USERFILE);
- exit(0);
+ exit(1);
}
if ((newfile=open(newpath,O_WRONLY|O_CREAT,0600))<0)
{
perror(newpath);
- exit(0);
+ exit(1);
}
while(read(oldfile,&user,sizeof(user))>0)
@@ -34,18 +36,21 @@
}else
{
time_t when = user.lastlogout;
+ char *line = NULL;
+ size_t len = 0;
+ char buff[20];
printf("Name: %s\tRname: %s\n",user.name,user.realname);
printf("Contact: %s\n",user.contact);
- show_user_stats(user.status,buff,true);
+ show_user_stats(user.status,buff,1);
printf("Status [%s]\n",buff);
printf("Lastlogin %s", ctime(&when));
printf("\nDelete(y/n)?");
- get_str(buff,3);
- if(buff[0]!='y')
+ while ((getline(&line, &len, stdin) < 1) || line == NULL);
+ if (*line != 'y')
{
write(newfile,&user,sizeof(user));
}
- if (buff[0]=='t') tt=user.lastlogout;
+ if (*line == 't') tt = user.lastlogout;
}
}
close(newfile);
Modified: trunk/src/utils/fixuser.c
===================================================================
--- trunk/src/utils/fixuser.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/utils/fixuser.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -2,27 +2,28 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
+#include <string.h>
+#include <unistd.h>
-#include "../bb.h"
-#include "../user.h"
+#include <bb.h>
+#include <user.h>
+#include <files.h>
-main()
+int main(void)
{
struct person user;
- char path[1024];
+ const char *path = USERFILE;
int count=0;
int ff, ff2;
- snprintf(path, 1024, "%s/users.bb", HOMEPATH);
-
if ((ff=open(path, O_RDONLY))<0) {
fprintf(stderr, "%s: %s", path, strerror(errno));
- exit(0);
+ exit(1);
}
if ((ff2=open("users.bb.new", O_WRONLY|O_CREAT, 0600))<0) {
fprintf(stderr, "users.bb.new: %s", strerror(errno));
- exit(0);
+ exit(1);
}
while (read(ff, &user, sizeof(user))>0) {
@@ -32,7 +33,7 @@
if (!strcasecmp(user.name, "dot")) {
close(ff2);
close(ff);
- exit(0);
+ exit(1);
}
}
close(ff);
Modified: trunk/src/utils/listuser.c
===================================================================
--- trunk/src/utils/listuser.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/utils/listuser.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -2,25 +2,26 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
+#include <string.h>
+#include <unistd.h>
-#include "../bb.h"
-#include "../user.h"
+#include <bb.h>
+#include <user.h>
+#include <files.h>
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
struct person user;
- char path[1024];
+ const char *path = USERFILE;
int count=0;
int ff;
- if (argc<2)
- snprintf(path, 1024, "%s/users.bb", HOMEPATH);
- else
- snprintf(path, 1024, "%s", argv[1]);
-
+ if (argc > 1)
+ path = argv[1];
+
if ((ff=open(path, O_RDONLY))<0) {
- fprintf(stderr, "%s: %s", path, strerror(errno));
- exit(0);
+ fprintf(stderr, "%s: %s\n", path, strerror(errno));
+ exit(1);
}
while (read(ff, &user, sizeof(user))>0) {
Modified: trunk/src/utils/sizes.c
===================================================================
--- trunk/src/utils/sizes.c 2013-10-31 19:07:45 UTC (rev 1346)
+++ trunk/src/utils/sizes.c 2013-10-31 20:52:36 UTC (rev 1347)
@@ -3,17 +3,13 @@
#include <strings.h>
#include <stdlib.h>
+#include <mesg.h>
#include "bb.h"
#include "user.h"
#include "files.h"
#include "folders.h"
-#include "mesg.h"
-void addmap(char *map, const char *name, char key, unsigned long size, void * offset, void * base);
-void showmap(const char *map, unsigned long size);
-
-
-void addmap(char *map, const char *name, char key,
+static void addmap(char *map, const char *name, char key,
unsigned long size, void * offset, void * base)
{
int i;
@@ -23,7 +19,7 @@
map[i]=key;
}
-void showmap(const char *map, unsigned long size)
+static void showmap(const char *map, unsigned long size)
{
int i;
printf("memmap: ");
More information about the mw-devel
mailing list